opencart non www to www adds index.php?_route_=

this time it is about opencart and seo client needs to redirect site from non www to www all time so we added rule in .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

 

i added this to the end of file and it worked good but i had problem and it was showing index.php?_route_= after the base link like this

http://www.layoudesign.com/index.php?_route_=blog

instead of

http://www.layoudesign.com/blog

 

and after searching Google i found the solution

it was by putting these lines before the standard rules like this :

RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

 

hope it will help someone

 

 

Advertisements