【发布时间】:2016-05-09 11:42:55
【问题描述】:
我在旧网站上使用此重定向:
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^oldfolder(/.*)?$ http://newsite.com/newfolder$1 [L,R=301,NC,NE]
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301,NE]
这个重定向代码帮助我:
- 首先,在我的新网站上将 www 重定向到非 www
- 其次,将带有oldfolder的oldsite URL重定向到带有newfolder的newsite URL
问题是一些旧的 URL 在其结构上有 index.php 并且重定向是错误的。例如:
oldsite.com/index.php/oldfolder/....
重定向到
newsite.com/index.php/oldfolder/....
但正确的重定向应该是到
newsite.com/index.php/newfolder/.... 或 newsite.com/newfolder/....
如何更改我的重定向代码以正确重定向到我的新文件夹结构 URL?
【问题讨论】:
标签: php apache .htaccess redirect mod-rewrite