如何写我的重写器,这样我就可以有一个友好的url



我的SEO专家让我在Opencart安装中执行HTTP 301重定向到友好的URL。这个Opencart安装使用SEO url,所以我有这个url(Opencart中的本地url):http://www.qcbikeshop.com/index.php?route=information/information&information_id=9

并且SEO url是:http://www.qcbikeshop.com/Livraison-Gratuite

然而,我的SEO专家希望我做一个HTTP301重定向,这样当有人访问本地URL(第一个)时,他会重定向到SEO URL。

当我尝试在.htaccess中做这件事时,Apache说这是一个无休止的循环,我理解它。但我没有找到如何实现我想要做的事情。

以下是我当前在.htaccess文件中的重写内容:

RewriteBase /
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]
RewriteCond %{HTTP_HOST} ^qcbikeshop.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www.qcbikeshop.ca$
RewriteRule ^/?$ "http://qcbikeshop.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^qcbike.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.qcbike.com$
RewriteRule ^/?$ "http://qcbikeshop.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^qcbike.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www.qcbike.ca$
RewriteRule ^/?$ "http://qcbikeshop.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^spherikbike.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www.spherikbike.ca$
RewriteRule ^/?$ "http://www.spherikbike.com/" [R=301,L]
Redirect 301 /mtb-comp-fr.html http://www.qcbikeshop.com/accessoires/pompes-velo/mtb-comp-fr.html

CPanel重写工具为我上面的例子生成这个:

RewriteCond %{HTTP_HOST} ^qcbikeshop.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.qcbikeshop.com$
RewriteRule ^index.php$ "http://www.qcbikeshop.com/Livraison-Gratuite" [R=301,L]

我觉得这很不对。谢谢你的帮助!

您可以将此规则置于其他规则之上,并查看它是如何为您工作的。

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php?information/information&information=9
RewriteRule .* /Livraison-Gratuite? [R=301,L]

相关内容

最新更新