OpenCart 中的手动 301 重定向

Manual 301 redirects in OpenCart

我在我的 OpenCart(版本 1.5.6)网站上更改了几个 URL,然后又更改了一次; Google 开始提醒我 link 已经死了,现在我正在尝试通过在 .htaccess 中添加手动 301 重定向来解决问题:我以前每次使用 WordPress 时都会这样做。

我完全可以手动完成每个 link,实际上我更喜欢这种方法。

但是,每当我在 .htaccess 中添加一行时,它往往会被忽略。

以下是我的 .htaccess 文件的内容:

<Files *.ini>
Order deny,allow
Deny from All
</Files>

SetEnv PHPRC /home/shopurl/
Options +FollowSymlinks

Options -Indexes

<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On

RewriteCond %{HTTP_HOST} ^shopurl.com
RewriteRule (.*) http://www.shopurl.com/ [R=301,L]


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_= [L,QSA]

<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
<ifModule mod_headers.c>
    Header append Vary User-Agent
</ifModule>

<FilesMatch "\.(js|css|jpg|png|jpeg|gif|xml|json|txt|pdf|mov|avi|otf|woff|ico|swf)$">
    RequestHeader unset Cookie
    Header unset Cookie
    Header unset Set-Cookie
    ErrorDocument 404 'Not Found'
</FilesMatch>

我怎样才能成功地做到这一点?

RewriteBase / 行之后添加所有 RewriteRules,如下所示:

...
RewriteBase /

RewriteRule ^your-url$ /your-new-url [L,R=301]
RewriteRule ^your-page$ /your-new-page [L,R=301]
RewriteRule ^your-category$ /your-new-category [L,R=301]
RewriteRule ^your-product$ /your-new-product [L,R=301]

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
...

所以它重写了:

http://www.yoursite.com/your-url
- to -
http://www.yoursite.com/your-new-url

等...