参数为:“route = product / search”和“path = 0”。我已经尝试了很多东西但是我对.htaccess的了解有限。
我想重定向以下网址: www.example.com/index.php?route=product/search&path=0
要 www.example.com
无论我尝试什么,它似乎都不起作用。什么是最好的解决方案?
# 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/
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]
### below send all calls to www
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{QUERY_STRING} (^|&)route=product/search(&|$) [NC]
RewriteCond %{QUERY_STRING} (^|&)path=0(&|$) [NC]
RewriteRule ^index.php$ / [R=301,NC]
答案 0 :(得分:0)
将这些指令添加到您的主.htaccess
:
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)route=product/search(&|$) [NC]
RewriteCond %{QUERY_STRING} (^|&)path=0(&|$) [NC]
RewriteRule ^index.php$ /? [R=301,NC]
你还在第四个RewriteRule中丢失了RewriteCond(它阻止了重写时以index.php开头的url),你的.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/
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)
RewriteCond %{REQUEST_URI} !^index.php
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
### below send all calls to www
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{QUERY_STRING} (^|&)route=product/search(&|$) [NC]
RewriteCond %{QUERY_STRING} (^|&)path=0(&|$) [NC]
RewriteRule ^index.php$ /? [R=301,NC]