Reply New Topic
2010/1/8 3:54:16
#1
Offline
Home away from home

Restrict access via htaccess based on host

I want to restrict access to specific patterns to localhost only.

Current .htaccess:
RewriteEngine On
RewriteRule latest.html latest.php [L]
RewriteRule ^([^/]*)\.xml$ xmlfactory.php?id=$1 [L]

What I want to have is:
- Everybody should be allowed to access latest.html. The second rule however, should only apply for anyone not being localhost. So in case I'm going to visit the website via my browser I should see a 403 Forbidden. In case the server is querying itself, it should get access to the file.

Is it possible to do it with
RewriteCond %{REMOTE_ADDR} somehow?

Please help me


2010/1/8 11:34:44
#2
Offline
Home away from home

Re: Restrict access via htaccess based on host

Never mind. Seems not to work anyway.
However, in case someone knows: Please answer anyway. This might be helpful for someone else as well.

_________________
the german icms website : www.impresscms.de

2010/1/9 12:20:19
#3
Offline
Home away from home

Re: Restrict access via htaccess based on host

I am not sure which file you are trying to block - but its rather simple to do whatever the file is.

you would need to use an allow deny rule.
ex:
<Files ~ "^\.xml"> Order allow,deny Deny from all </Files>


You can do specific filenames whatever.

you can also allow say only certain refers to access.
<Files ~ "^\.xml"> Order allow,deny Deny from all Allow from .somedomain.com Allow from .someotherdomain.com </Files>


Check it

HTH


2010/1/9 12:25:39
#4
Offline
Home away from home

Re: Restrict access via htaccess based on host

The question was whether it's possible to allow access to certain files only for the server itself (not for access via the client = brower)

_________________
the german icms website : www.impresscms.de

2010/1/9 13:55:29
#5
Offline
Home away from home

Re: Restrict access via htaccess based on host

and it was answered.

Either I am not understanding the question - or you aren't understanding the answer.

using allow/deny does not block the server. just blocks http access for those on the deny list.


2010/1/10 2:57:45
#6
Offline
Home away from home

Re: Restrict access via htaccess based on host

ok then. I just got it wrong .
Thank you for your answer. I didn't know that it doesn't effect the server.

_________________
the german icms website : www.impresscms.de

Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.