glenelkins Posted July 16, 2010 Share Posted July 16, 2010 Any idea why this redirect is not working? So if a url like index.php?route=advertiser/category/category_name/ is typed it redirects to www.domain.net/category_name/ (as per another rule further down the page ) RewriteEngine On RewriteRule ^/index.php?route=advertiser/category/(.*)/$ http://www.domain.net/$1/ [L,R=301] ErrorDocument 404 /index.php?route=errors/index/404/ # rewrite urls to always redirect to www. version RewriteCond %{HTTP_HOST} !^www.couponsmania\.net$ RewriteRule ^(.*)$ http://www.couponsmania.net/$1 [L,R=301] # general url rewrites for seo friendly urls RewriteRule ^css/(.*)$ css/$1 [L] RewriteRule ^images/(.*)$ images/$1 [L] RewriteRule ^js/(.*)$ js/$1 [L] RewriteRule ^admin/$ index.php?route=admin/ [L] RewriteRule ^admin/(.*)/$ index.php?route=admin/$1/ [L] RewriteRule ^admin/(.*)/(.*)/$ index.php?route=admin/$1/$2/ [L] RewriteRule ^coupons/(.*)/$ index.php?route=advertiser/index/$1/ [L] RewriteRule ^coupons/(.*)/(.*)/$ index.php?route=advertiser/index/$1/$2/ [L] RewriteRule ^hot-deals/$ index.php?route=hotdeals/ [L] RewriteRule ^new-coupons-deals/$ index.php?route=newcouponsdeals/ [L] RewriteRule ^about-us/$ index.php?route=page/get/about-us/ [L] RewriteRule ^help/$ index.php?route=page/get/help/ [L] RewriteRule ^sitemap/$ index.php?route=sitemap/ [L] RewriteRule ^sitemap/(.*)/$ index.php?route=sitemap/category/$1/ [L] RewriteRule ^sitemap/(.*)/(.*)/$ index.php?route=sitemap/category/$1/$2 [L] RewriteRule ^(.*)/$ index.php?route=advertiser/category/$1/ [L] RewriteRule ^(.*)/(.*)/$ index.php?route=advertiser/category/$1/$2/ [L] OPTIONS -INDEXES <Files .htaccess> order allow,deny deny from all </Files> Link to comment https://forums.phpfreaks.com/topic/207953-htaccess-301-redirect-does-not-work/ Share on other sites More sharing options...
cags Posted July 16, 2010 Share Posted July 16, 2010 Everything after the question mark in a URL is part of the QUERY_STRING, RewriteRules do not match against QUERY_STRING only REQUEST_URI. You would have to use a RewriteCond, but you will likely get a rewrite loop. Link to comment https://forums.phpfreaks.com/topic/207953-htaccess-301-redirect-does-not-work/#findComment-1087126 Share on other sites More sharing options...
glenelkins Posted July 17, 2010 Author Share Posted July 17, 2010 yeh thanks thats what i thought would happen too Link to comment https://forums.phpfreaks.com/topic/207953-htaccess-301-redirect-does-not-work/#findComment-1087390 Share on other sites More sharing options...
glenelkins Posted July 17, 2010 Author Share Posted July 17, 2010 This is really annoying. This code just won't redirect at all. The new site urls are like http://www.domain.com/category-name/ which relates to the old www.domain.com/index.php?route=/advertiser/category/category-name/ RewriteCond %{QUERY_STRING} ^route=(.*)$ RewriteRule ^/index.php$ http://www.domain.com/$1/ [L,R=301] Link to comment https://forums.phpfreaks.com/topic/207953-htaccess-301-redirect-does-not-work/#findComment-1087394 Share on other sites More sharing options...
cags Posted July 17, 2010 Share Posted July 17, 2010 Generally speaking when working with .htaccess you will not want a forward slash at the start of the RewriteRule. Link to comment https://forums.phpfreaks.com/topic/207953-htaccess-301-redirect-does-not-work/#findComment-1087412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.