regex - 301 重定向到 URL 中带有 # 的域
问题描述
我目前正在尝试重定向以下内容:
bar.com/foo ====> bar.com/bar.html#/#
我的重定向规则如下:
RewriteEngine On
RewriteRule ^/foo$ bar.com/bar.html#/# [R=301,L,NC]
这是我运行测试 curl 时的输出:
301 http://bar.com/foo ======>
https://bar.com/bar.html%23/%23
它返回一个 301 HTTP 响应;但是,这些 %23 字符是表示重定向后 # 将出现在 URL 中的编码指示,还是 URL 的文字表示?如果这是不正确的,我需要做任何转义吗?
在此先感谢您的帮助。
解决方案
使用NE
选项避免编码:
RewriteEngine On
RewriteRule ^/?foo/?$ /bar.html#/# [R=301,L,NC,NE]
确保在新浏览器中测试它以避免旧缓存。
推荐阅读
- javascript - 如何在reactjs中验证多表条目应用程序onsubmit
- symfony - 从单一存储库加载一个特定的作曲家包
- python - 如何克服无法加载 vtkClientServerPython?
- java - 如何将 LocalDate 转换为特定的日期时间格式
- python - 从笔记本中的其他选项卡访问变量
- git - GIT:无效路径'.editorconfig'
- python - ModuleNotFoundError python - 将我的模块目录添加到窗口的路径不起作用
- javascript - wicked_pdf 目录后的起始页码
- android - 保存 SharedPreferences 文件以进行备份
- angular - Angular 11 - 不推荐使用订阅:使用观察者而不是完整的回调