.htaccessmod-rewriteseoopencart

Remove index.php?route= from OpenCart


I'm a .NET developer but my friend called me for support.I made some changes with .htaccess but i'm corrupted SEO.

Everything started with "www" tag on url.I see we get some errors when we are not using "www" and i'm changed .htaccess.I'm added rewrite rule and redirected mysite.com to www.mysite.com.Our problems are solved but now we have another problem.

We are using Opencart - SEO and it's enabled.Our products seems like

http://www.mysite.com/epson-claria-uyumlu-yazici-kartus-dolum-murekkebi-500g.html

when we are reaching with www.

But if i remove "www" tag on url, it seems like

http://www.mysite.com/index.php?_route_=epson-claria-uyumlu-yazici-kartus-dolum-murekkebi-500g.html

and it corrupt SEO.

I want to see second url like first one.

I'm tried play with seo_url.php , .htaccess but it doesn't change anyting.

I'm also tried solution on Remove index.php?route=common/home from OpenCart but it's not worked for me.

Now my seo_url.php is default, i get back my changes.And my .htaccess is

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

RewriteBase /
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]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ http://www.mysite.com? [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L] 

RewriteRule ^(.*)$ index.php?_route_=$1 [L]

Please help me before i get crazy.I spend 3 hours for that.

Thank you for all, Greetings


Solution

  • Try This Its working for me using .htaccess.

    RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\ ]*)
    RewriteRule ^ /%1? [L,R]