Website use the opencart cms, SEO url enabled, so the .htaccess looks :
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
all works perfect, but i wanted to add the 301 redirect from non www to www, so i added:
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
It works, but when i try to redirect link with category or product it adds “index.php?route=”
Example:
“www.example.com/cats”, if i try “example.com/cats” without “www” the link will look http://www.example.com/index.php?route=cats
You need to add all of your redirects before any routing rules (e.g. the rules you have that route things to
index.php. So your htaccess file needs to look something like this: