Opencar 301使用?route =重定向问题

时间:2013-09-18 18:44:40

标签: .htaccess redirect

我已将网站从WordPress重组为Opencart,因此所有网址都已更改。我试图用新的重定向我的旧产品页面,但它没有重定向,因为OpenCart添加了一些奇怪的?route=等等。

这是我的.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]
Redirect 301 /store/products/old-item-name/ http://store.mydomain.com/new-item-name

重定向到这个奇怪的网址

http://store.mydomain.com/new-item-name?_route_=store/products/old-item-name/

感谢您的大力帮助..百万谢谢

3 个答案:

答案 0 :(得分:1)

这是因为Redirect是mod_alias的一部分,其他一切都是mod_rewrite的一部分。这两个模块应用于URL文件处理管道的不同点,在这种情况下,您的请求将被两个模块应用。您需要将重定向移动到顶部并坚持使用mod_rewrite:

删除:

Redirect 301 /store/products/old-item-name/ http://store.mydomain.com/new-item-name

并将其添加到顶部:

RewriteRule ^products/old-item-name(/.*)$ http://store.mydomain.com/new-item-name$1 [L,R=301]

答案 1 :(得分:0)

上一个Redirect 301规则被以前的RewriteRule规则重定向。一般来说,不建议混用mod_aliasmod_rewrite

尝试将最后RewriteRule更改为:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# your 301 rules from old to new
RewriteRule ^products/old-item-name(/.*|)$ new-item-name$1 [NC,L,R=301]

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|jpe?g|png|js|css)$ [NC]
RewriteRule ^(.*)$ index.php?_route_=$1 [L,QSA]

答案 2 :(得分:0)

从Ashop迁移到OpenCart时出现了类似的问题

旧网址的格式 http://www.example.com/p/productid/manufacturer-productname.html

并被重定向到

http://www.example.com/manufacturer/

解决方案是

RewriteRule ^(.*)manufacturer(-.*|)$ http://www.example.com/manufacturer/ [NC,L,R=301]

希望能帮助某人......

请注意,您无法直接匹配制造商,因为重定向循环会发生,因此匹配包含' - '

相关问题