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
Share on other sites

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
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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.