Jump to content

.htaccess - 301 redirect does not work!


glenelkins

Recommended Posts

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

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.