opencart 2.3.0.2 htaccess 301重定向

时间:2019-03-20 17:03:43

标签: php .htaccess opencart url-redirection

我尝试了在网上找到的其他解决方案,但没有锻炼。 我的htaccess文件如下:

Options +FollowSymlinks
Options -Indexes
<FilesMatch "(?i)((\.tpl|\.ini|\.log))">
 Order deny,allow
 Deny from all
 </FilesMatch>

RewriteEngine On
Redirect 301 ^abc https://www.example.com/abc-products


RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/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]

我原本希望example.com/abc的网址重定向到example.com/abc-products,但是它正在重定向到example.com/abc-products?_route_=abc

我也尝试了以下方法

Redirect 301 ^abc https://www.example.com/abc-products
Redirect 301 ^/abc /abc-products
Redirect 301 /abc /abc-products

但是结果始终是https://www.example.com/abc-products?_route_=abc

2 个答案:

答案 0 :(得分:1)

重试

RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L] RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]

添加

 RewriteRule ^abc/(.*)$ /abc-products/$1 [R=301,NC,L]

答案 1 :(得分:1)

我认为您应该尝试此代码。 100%工作。

Options +FollowSymlinks
Options -Indexes
<FilesMatch "(?i)((\.tpl|\.ini|\.log))">
 Order deny,allow
 Deny from all
 </FilesMatch>

RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
Redirect 301 / https://www.example.com/abc-products
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]

如果运行不正常。告诉我一声。 谢谢