Che*_*eng 3 apache .htaccess mod-rewrite redirect
通过使用以下.htaccess
RewriteEngine On
RewriteRule ^([0-9]+)/([0-9]+)$ /api/web/index.html#$1/$2 [R=301,NC,L]
Run Code Online (Sandbox Code Playgroud)
用户在浏览器中键入以下URL时.
http://localhost:8080/1/2
Run Code Online (Sandbox Code Playgroud)
我期待,Apache将执行内部重定向,并在浏览器中更改显示的URL(通过R = 301).
http://localhost:8080/api/web/index.html#1/2
Run Code Online (Sandbox Code Playgroud)
在浏览器中更改显示的URL非常重要.这是为了确保index.htmlJavaScript可以正确解析url.
但是,我真正得到的是
http://localhost:8082/api/web/index.html%231/2
Run Code Online (Sandbox Code Playgroud)
我会得到Apache错误.
Apache错误认为,我希望获取一个名为2目录的文件api/web/index.html%231/
有什么我可以通过.htaccess仅修改来解决这个问题吗?
它#被编码为%23.尝试使用NE规则中的标志:
RewriteRule ^([0-9]+)/([0-9]+)$ /api/web/index.html#$1/$2 [R=301,NC,L,NE]
Run Code Online (Sandbox Code Playgroud)
该NE标志告诉mod_rewrite不要对URI进行编码.
| 归档时间: |
|
| 查看次数: |
2378 次 |
| 最近记录: |