apache - htaccess 重定向 url 与 anchor 标记

标签 apache .htaccess redirect mod-rewrite

我正在尝试将 URL 重定向到带有 anchor 标记的页面。重定向有效,但如何在重定向后保留原始 URL 而不是重定向后的 URL。

我想将 www.example.com/caves/ 重定向到 www.example.com/trips.html#caves

当我重定向时,我得到 URL www.example.com/trips.html#caves 但希望它保留 www.example.com/caves/

我花了很长时间寻找答案,但没有运气,任何帮助将不胜感激

这是我在 htaccess 中的代码

RewriteEngine on

RewriteRule ^Caves/(.*) /trips.html#Caves [NE,L,R]

最佳答案

我怀疑它能做到。 anchor 是一个客户端指令,你不能用服务器端重写来“隐藏”它(浏览器如果看不到 anchor 就不能跳转到 anchor ),所以 anchor 必须在地址栏 URL 中。

关于apache - htaccess 重定向 url 与 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39560646/

相关文章:

java - 自动完成功能在 Apache ISIS Action 中不起作用

apache - WAMP Windows 服务器上的 Laravel 异常

r - 如何在读取 R 中的行之前等待网页加载?

javascript - 如何在移动网站上创建 "Desktop Version"链接而不重定向到移动网站

css - 用于图像、css 和 js 的暂存服务器 .htaccess

php - 缺少 mysqli 扩展。请检查您的 PHP 配置

django - Apache 抛出错误 500 : Internal Server Error when GET from localhost/internal network

php - SSL 重定向 .htaccess 不工作

apache - 捕获所有 .htaccess - 仅当之前未找到任何内容时

正则表达式与我的字符串的第一次出现不匹配