PDA

View Full Version : htaccess redirect question


mhackl
03-10-2010, 06:38 PM
I have moved my forum from a "/forums/" sub-directory into the sites root directory. I have included the following code in my .htaccess file to redirect search engine links to the appropriate page in the sites new location and this is working great except I need to make an exception for the "/forums/images/" directory. This is where I need help.

Current code to redirect:
RewriteRule ^forums(.*)$ http://www.domain.com/$1 [L,R=301]

How do I add a condition or exception to this to allow the "/forums/images/" to not be redirected?

borbole
03-10-2010, 07:24 PM
I have moved my forum from a "/forums/" sub-directory into the sites root directory. I have included the following code in my .htaccess file to redirect search engine links to the appropriate page in the sites new location and this is working great except I need to make an exception for the "/forums/images/" directory. This is where I need help.

Current code to redirect:
RewriteRule ^forums(.*)$ http://www.domain.com/$1 [L,R=301]

How do I add a condition or exception to this to allow the "/forums/images/" to not be redirected?


Try add a RewriteCond with a negative pattern that excludes the images folder.

Something like this for ex:

RewriteCond %{REQUEST_URI} !^/forums/images/

mhackl
03-10-2010, 07:40 PM
Found the answer to my own question.
RewriteCond %{REQUEST_URI} !(images)
RewriteRule ^forums(.*)$ http://www.domain.com/$1 [L,R=301]

--------------- Added 1268257272 at 1268257272 ---------------

Try add a RewriteCond with a negative pattern that excludes the images folder.

Something like this for ex:

RewriteCond %{REQUEST_URI} !^/forums/images/


Thank you! I responded to my own post before I saw that you had responded. Thank you for your response.

borbole
03-10-2010, 07:50 PM
No problem.