Welcome to WebmasterWorld Guest from 54.145.176.120

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Setting Redirection Rule Exceptions

How to set exceptions to a redirect rule in HTACCESS

   
9:00 am on Jun 10, 2008 (gmt 0)

5+ Year Member



Friends,

I am using this code to redirect www.example.com/index.php to /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ http://www.example.com/$1 [R=301,L]

Now I want to set an exception to this redirection rule so that URLs such as www.example.com/admin/index.php are not redirected to www.example.com/admin/

This rule is creating problems for Admin login for the site which is made by a CMS.

Let me know how to set exceptions to this rule.

Thanks a lot in advance!

10:59 pm on Jun 10, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Add a RewriteCond with a negative-match pattern:

RewriteCond %{REQUEST_URI} !^/admin/

This will prevent the rule being applied to any resource in the /admin/ subdirectory.

Jim

6:05 am on Jun 11, 2008 (gmt 0)

5+ Year Member



Thanks Jim,

So would the entire code look like this?

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteCond %{REQUEST_URI} !^/admin/
RewriteRule ^(.*)index\.php$ http://www.example.com/$1 [R=301,L]

12:18 pm on Jul 3, 2008 (gmt 0)

5+ Year Member



Anybody can help me with this?

Sorry for bumping the thread but I really need a solution to this...

Thanks!

2:12 pm on Jul 3, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



We're here to help, not to do the testing for you... :)

Your code should work fine.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month