htaccess mod 重写

发布于 2025-01-07 11:34:55 字数 377 浏览 0 评论 0原文

我在重写 url 时遇到问题。我有以下规则工作正常:

RewriteRule ^([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

显示网址如下:

domain.com/theme/pg

我需要将网址重写为 domain.com/theme#pg 我认为以下内容可以工作,但事实并非如此't:

RewriteRule ^([^/\.]+)/?#([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

我做错了什么?

I'm having trouble with url rewriting. I have the following rule working fine:

RewriteRule ^([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

which displays the url as follows:

domain.com/theme/pg

What i need is for the the url to rewrite to domain.com/theme#pg I thought the below would work, but it doesn't:

RewriteRule ^([^/\.]+)/?#([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

避讳 2025-01-14 11:34:55

URL 中的 # 是客户端的东西 - 你根本不应该在服务器上获取它。您可以重写包含锚点的URL,如下所示:

但不来自包含#的URL - 根本无法到达服务器。

# in the URL is the client-side thing - you should not get that on the server at all. You can rewrite to the URL containing an anchor, as given e.g. here:

but not from the URL containing a # - that would not get to the server at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文