【发布时间】:2013-03-04 19:44:16
【问题描述】:
我想将子目录中的所有文件重定向到它们的新根 URL。
旧网址是
www.domain.com/subdirectory/filename-here.html
新位置是
www.domain.com/filename.here.html
旧网址已在 Google 中列出,需要对这些网址进行某种重定向。 我确定 htaccess 是去这里的方式,但不确定解决方案。
【问题讨论】:
我想将子目录中的所有文件重定向到它们的新根 URL。
旧网址是
www.domain.com/subdirectory/filename-here.html
新位置是
www.domain.com/filename.here.html
旧网址已在 Google 中列出,需要对这些网址进行某种重定向。 我确定 htaccess 是去这里的方式,但不确定解决方案。
【问题讨论】:
RewriteEngine on
RewriteRule %{REQUEST_URI} ^/subdirectory/.*
RewriteRule subdirectory/(.*)$ /$1 [R=301,L]
在here 上测试。如果它不起作用 - 以这种方式为[^/] 添加屏蔽:[^\/]
【讨论】: