Forum Moderators: phranque

Message Too Old, No Replies

rewrite exception

Best method for exeception to rewrite rules

         

JamesTrix

12:49 am on Sep 27, 2008 (gmt 0)

10+ Year Member



Here is my current rewrite rule at the moment it redirects all traffic unless you have your ip address listed to /host/ and it works perfectly.


RewriteBase /

# If not remote IP address 1

RewriteCond %{REMOTE_ADDR} !^144\.104\.245\.85

# And if not remote IP address 2

RewriteCond %{REMOTE_ADDR} !^210\.240\.198\.22

# Then redirect all requests to /host

RewriteRule !^host/ [mysite.com...] [R=301,L]

What I want to do is add an exception for 2 directories

/tracker/ and /list/

What is the best way to do this should I just add the following code before the above rewrite code

RewriteCond %{REQUEST_URI} !^tracker
RewriteRule /tracker/ [L]

RewriteCond %{REQUEST_URI} !^list
RewriteRule /list/ [L]

Is that the correct way of doing it or is there another correct method ? Thanks for your help :-)

jdMorgan

1:42 am on Sep 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...or just add one more RewriteCond to your existing rule:

RewriteCond %{REQUEST_URI} !^/(trackerŠlist)/

Replace the broken pipe "Š" character with a solid pipe before use; Posting on this forum modifies the pipe characters. (The pipe character means 'OR' in this context)

Jim

JamesTrix

2:53 am on Sep 27, 2008 (gmt 0)

10+ Year Member



Thanks jdMorgan as aways it worked right away.