[英]Redirect /file to /folder/file using htaccess
我想從example.com/file.extension
重定向到example.com/folder/file.extension
。
我想知道這是否可能,而且我真的不知道該去哪里。
擴展名可以是任何類型,例如.mp3
, .png
或.exe
編輯-我已經弄清楚了我需要的東西,因為它可以工作,但是我需要排除不應該重寫的東西,例如php,css,html:
RewriteRule ^([^/.]+)\.(.+)$ /folder/$1.$2 [QSA,L]
將/file.extension
重定向到/folder/file.extension
您可以使用以下RedirectMatch
RedirectMatch 301 ^/([^/.]+)\.(.+)$ http:// example.com/folder/$1.$2
我已經采取了張貼和修改它以得到我的答案。
RewriteRule ^([^ /。] +)。(((txt | png | jpeg | jpg | mp3 | mp4 | bmp | gif | exe | dmg))$ /folder/$1.$2 [QSA,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.