我試圖在主目錄的.htaccess文件中使用RewriteRule將一個子目錄重定向到另一個子目錄。htaccess如果沒有結尾的斜槓,RewriteRule不能正常工作
例如:http://website.com/subdir應重寫爲http://website.com/another_dir/destination_dir,但用戶仍應在地址欄中看到http://website.com/subdir。
如果用戶使用尾部斜線結束URL,則此功能完美無缺。例如:http://website.com/subdir/(生成一個200
然而,如果省略了斜線,則產生301重定向和我們所看到的不希望的目標目錄例如,http://website/subdir將用戶重定向到http://website/another_dir/destination_dir
下面是有關部分。的.htaccess的:
# URL Rewriting:
RewriteEngine On
RewriteBase/
...
# Redirect subdirectories:
RewriteRule ^subdir(.*)$ another_dir/destination_dir$1 [PT,NC,QSA,L]
任何援助表示讚賞