1
有很多這樣的問題,但我無法準確找到解決方案。我打開example.com/smth1/smth2/media_files
。我想將.htaccess
文件放在media_files
目錄中,該目錄將所有鏈接重定向到example.com/smth1/smth2/new_media_files
。.htaccess直接從子文件夾中重定向
請注意,smth1
等是動態的,所以我不能在.htaccess
文件中輸入硬編碼。
以及如何重寫到相同的域子文件夾?即我想'media_files'的內容被重定向到兄弟文件夾中,名爲'new_media_files' –
然後使用:'RewriteRule^media_files(/.*)?$/new_media_files $ 1 [L,NC]' – anubhava
非常感謝。最後一個問題: 如果url是:'/ smth/another1/another2/media_files /'並且想重定向'/ smth/another1/another2/new_media_files /'那麼我應該使用靜態短語:'/ smth/another1/another2' ?但如果父文件夾是動態的,我只知道,'new_media_files'駐留在相同的位置,'media_files'在這裏.. –