homepage Welcome to WebmasterWorld Guest from 54.145.183.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Setting Redirection Rule Exceptions
How to set exceptions to a redirect rule in HTACCESS
pro_seo

5+ Year Member



 
Msg#: 3671039 posted 9:00 am on Jun 10, 2008 (gmt 0)

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!

 

jdMorgan

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



 
Msg#: 3671039 posted 10:59 pm on Jun 10, 2008 (gmt 0)

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

pro_seo

5+ Year Member



 
Msg#: 3671039 posted 6:05 am on Jun 11, 2008 (gmt 0)

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]

pro_seo

5+ Year Member



 
Msg#: 3671039 posted 12:18 pm on Jul 3, 2008 (gmt 0)

Anybody can help me with this?

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

Thanks!

jdMorgan

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



 
Msg#: 3671039 posted 2:12 pm on Jul 3, 2008 (gmt 0)

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

Your code should work fine.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved