从 OpenCart 中删除 index.php?route=

cod*_*ius 1 .htaccess seo opencart

我是 .NET 开发人员,但我的朋友打电话给我寻求支持。我对 .htaccess 进行了一些更改,但我的 SEO 已损坏。

一切都以 url 上的“www”标签开始。我看到当我们不使用“www”时会出现一些错误,我更改了 .htaccess。我添加了重写规则并将 mysite.com 重定向到 www.mysite.com。我们的问题已经解决了,但现在我们还有另一个问题。

我们正在使用 Opencart - SEO 并且它已启用。我们的产品看起来像

http://www.mysite.com/epson-claria-uyumlu-yazici-kartus-dolum-murekkebi-500g.html
Run Code Online (Sandbox Code Playgroud)

当我们到达 www.

但是如果我删除 url 上的“www”标签,它看起来像

http://www.mysite.com/index.php?_route_=epson-claria-uyumlu-yazici-kartus-dolum-murekkebi-500g.html
Run Code Online (Sandbox Code Playgroud)

它破坏了搜索引擎优化。

我想看到像第一个一样的第二个网址。

我试过玩 seo_url.php , .htaccess 但它没有改变任何东西。

我还尝试了从 OpenCart 删除 index.php?route=common/home 的解决方案,但它对我不起作用。

现在我的 seo_url.php 是默认的,我取回了我的更改。我的 .htaccess 是

# 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]
Run Code Online (Sandbox Code Playgroud)

请在我发疯之前帮助我。我为此花了 3 个小时。

谢谢大家,问候

小智 5

试试这个 它使用 .htaccess 对我有用。

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