ReWriteCond question ?

Oh, the strange things mod_rewrite does!

ReWriteCond question ?

Postby Mudder » Wed Jul 30, 2008 12:02 am

Hi there

I want to do a rewrite depending on which IP a person comes from. The following IP conditions are ignored, Can anyone see why ?

#Start
<Directory "/opt/htdocs/stuff">
Options +FollowSymLinks -Indexes
AllowOverride All
RewriteEngine on
### DO NOT DELETE
RewriteCond %{REMOTE_ADDR} !^192\.168\.193\.[1-255]$ [OR]
RewriteCond %{REMOTE_ADDR} !^192\.249\.[64-79]\.[1-255]$
RewriteRule ^images/corp/([^/]+)/([^/]+).pdf$ http://www.mydomain.co.za/docs/$1/$2.xml [L]
### End Force
Order allow,deny
Allow from all
</Directory>
#End

Any help will be much appreciated.
Mudder
 
Posts: 3
Joined: Tue Jul 29, 2008 11:55 pm
Location: Centurion, South Africa

Postby richardk » Wed Jul 30, 2008 3:38 pm

You want it to be and not or. And you can't have ranges like [1-255], it would be 1 to 2 and 5. Try
Code: Select all
RewriteCond %{REMOTE_ADDR} !^192\.168\.193\.(0{0,2}[0-9]|[01]?[0-9]{2}|2[0-4][0-9]|25[0-5])$
RewriteCond %{REMOTE_ADDR} !^192\.249\.0?(6[4-9]|7[0-9])\.(0{0,2}[0-9]|[01]?[0-9]{2}|2[0-4][0-9]|25[0-5])$
RewriteRule ^images/corp/([^/]+)/([^/]+)\.pdf$ http://www.mydomain.co.za/docs/$1/$2.xml [L]

(".pdf" should be "\.pdf".)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Mudder » Wed Jul 30, 2008 10:50 pm

Thanks - I will try this.
Mudder
 
Posts: 3
Joined: Tue Jul 29, 2008 11:55 pm
Location: Centurion, South Africa

Postby Mudder » Wed Jul 30, 2008 11:19 pm

Fantastic - that solved it for me. Thank you very much.
Mudder
 
Posts: 3
Joined: Tue Jul 29, 2008 11:55 pm
Location: Centurion, South Africa


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 13 guests

cron