【发布时间】:2015-05-06 22:40:51
【问题描述】:
我的 SEO 专家要求我在 Opencart 安装中执行 HTTP 301 重定向到友好 URL。这个 Opencart 安装使用 SEO url,所以我有这个 url(opencart 中的本机 url): http://www.qcbikeshop.com/index.php?route=information/information&information_id=9
并且 SEO 网址是: http://www.qcbikeshop.com/Livraison-Gratuite
但是,我的 SEO 专家希望我做一个 HTTP 301 重定向,以便当有人访问本机 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]
这对我来说似乎很不对劲。 感谢您的帮助!
【问题讨论】:
-
你目前的规则是什么?
-
帖子已编辑并添加了当前规则!感谢您的关注!
-
我看到的问题是它如何将本地 URL 映射到新的 SEO?这意味着在 SEO 友好规则中使用的本地 URL 没有任何内容,所以我看不出您将如何制定动态规则。看来您必须为从 Native 到 SEO 的每个重定向制定规则。
-
我认为 Opencart 会将本地 url 映射到新的 SEO 中。我已经用 CPanel Redirect 在 .htaccess 文件中为我尝试执行的操作生成的内容更新了我的帖子。
标签: .htaccess seo rewrite opencart friendly-url