0
我想在一個子目錄中的所有文件重定向到新的根URL。htaccess的子目錄的URL根
舊網址是
www.domain.com/subdirectory/filename-here.html
新位置
www.domain.com/filename.here.html
舊網址已經被列在谷歌和需要某種重定向這些的。 我確信htaccess是去這裏的路,但不確定解決方案。
我想在一個子目錄中的所有文件重定向到新的根URL。htaccess的子目錄的URL根
舊網址是
www.domain.com/subdirectory/filename-here.html
新位置
www.domain.com/filename.here.html
舊網址已經被列在谷歌和需要某種重定向這些的。 我確信htaccess是去這裏的路,但不確定解決方案。
RewriteEngine on
RewriteRule %{REQUEST_URI} ^/subdirectory/.*
RewriteRule subdirectory/(.*)$ /$1 [R=301,L]
測試here。如果行不通 - 添加屏蔽到[^/]
這樣:[^\/]
近乎完美......鏈接,是在一個子目錄中還可以得到的重定向到根。 E.g. www.domain.com/subdirectory/subdirectory2/filename.html 應該 www.domain.com/subdirectory2/file.html 可能嗎? – 2013-03-04 20:06:51
你只想刪除一個子目錄? – vmeln 2013-03-04 21:04:15
是的請,我想那:) – 2013-03-05 08:21:43