And*_*rea 2 regex apache .htaccess mod-rewrite
我需要自动将很多 url 像 /file%20name/ ore /file name/ 重定向到 /file+name/ 或 /file-name/。
我怎样才能用 .htacess 做到这一点?
在你的 .htaccess 中试试这个规则:
RewriteEngine on
Options +FollowSymlinks
# executes repeatedly as long as there are more than 1 spaces in URI
RewriteRule "^(\S*)\s+(\S* .*)$" $1+$2 [N,NE]
# executes when there is exactly 1 space in URI
RewriteRule "^(\S*)\s(\S*)$" /$1+$2 [L,R=302,NE]
Run Code Online (Sandbox Code Playgroud)
R=301 将重定向为 https 状态 301
L 将制定最后的规则
NE 用于无编码 URI
| 归档时间: |
|
| 查看次数: |
8715 次 |
| 最近记录: |