Forum Moderators: phranque
I'm trying to 301 redirect an "exact url" to its new location via htaccess, however I'm also redirecting all http://www.example.com traffic to http://example.com
My .htaccess is as follows:
redirect 301 http://www.example.com/type_new/widget_blue/size_small/ http://example.com/new/blue/small/
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
For some reason, the RewriteCond/RewriteRule is picked up first, so I'm seeing multiple 301 redirects. If I comment out the RewriteCond/RewriteRule it works fine.
How do I make the redirect take preference over the RewriteCond/RewriteRule?
[edited by: jdMorgan at 7:09 pm (utc) on Dec. 15, 2009]
[edit reason] example.com [/edit]
RewriteRule ^type\_new\/widget\_blue\/size\_small\/$ /new/blue/small/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com.tld/$1 [R=301,L]
[edited by: jdMorgan at 7:10 pm (utc) on Dec. 15, 2009]
[edit reason] example.com [/edit]
So use either:
RewriteRule ^type_new/widget_blue/size_small/$ http://example.com/new/blue/small/ [R=301,L]
#
RewriteCond %{HTTP_HOST} ^www\.example\.com\.?(:[0-9]+)?$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteRule ^type_new/widget_blue/size_small/$ http://example.com/new/blue/small/ [R=301,L]
#
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]