【发布时间】:2011-04-08 01:48:27
【问题描述】:
我只是将我的网站从 asp 迁移到 opencart。在 .htaccess 中,我想做一些重定向,以便我的客户可以使用旧链接访问
在 .htaccess 中
redirect 301 /contact.asp http://www.example.com/index.php?route=information/contact_us
redirect 301 /downloads.asp http://www.example.com/downloads
对于完美运行的“联系我们”,但是对于下载 url,它无法正常运行。
当我访问http://www.example.com/downloads.asp 时,它将重定向到http://www.example.com/downloads?_route_=downloads.asp
并且 Opencart 显示它是找不到页面。
对于http://www.example.com/downloads,我们在后端系统中设置了 SEO 友好的 URL。
我们可以访问
http://www.example.com/information/downloads
http://www.example.com/downloads
但我们无法通过正常链接访问
http://www.example.com/index.php?route=information/downloads
以下是我的完整 .htaccess
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
redirect 301 /contact.asp http://www.example.com/index.php?route=information/contact_us
redirect 301 /downloads.asp http://www.example.com/downloads
============另一个测试========================
我在本地主机上对此进行了一些测试,我发现这是一个非常有趣的结果。但是,我的问题还没有解决。
我从http://localhost/example 和http://example 运行.htaccess(添加了虚拟目录)
redirect 301 /example/downloads.asp http://localhost/example/downloads/
和
redirect 301 /downloads.asp http://example/downloads/
然后我尝试从本地主机(http://example)重定向到我的实时版本链接
redirect 301 /downloads.asp http://www.example.com/downloads/
我访问http://example/downloads.asp
浏览器重定向到我
http://www.example.com/downloads?route=downloads.asp
注意
在 LIVE 版本中,我没有添加任何重定向代码 [非常确定]
但在直播版本中,我是直接输入访问
http://www.example.com/downloads
我不知道为什么会出现从 localhost 重定向 301 到 live 版本
http://www.example.com/downloads?route=downloads.asp
有什么想法吗?
【问题讨论】:
标签: .htaccess redirect opencart