mod-rewrite 正则表达式有什么问题?

发布于 2024-09-08 22:35:52 字数 312 浏览 4 评论 0原文

我正在尝试将

tagged.php?flag=parameter&page=1

重写为

/parameter/?page=1

所以我使用:

RewriteRule Hotties/?(.*) tagged.php?flag=parameter&page=$1

但是我得到的结果是:

/parameter/?page=

哪个是“1”。我不确定缺少什么。显然问题出在 (.) 和“=”上,但我不确定出了什么问题。我也尝试过 (.$) 但没有解决它。

I am trying to rewrite

tagged.php?flag=parameter&page=1

into

/parameter/?page=1

So I am using:

RewriteRule Hotties/?(.*) tagged.php?flag=parameter&page=$1

However the result I am getting is:

/parameter/?page=

Which is the "1". I am not sure what is missing. Clearly the issue is with the (.) and the "=" but I am not sure what is wrong. I also tried (.$) which did not fix it.

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

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

发布评论

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

评论(1

乄_柒ぐ汐 2024-09-15 22:35:52

根据 文档,您需要匹配 URL 路径和单独的查询字符串。如果这确实是你的问题

我正在尝试重写

tagged.php?flag=parameter&page=1

进入

/参数/?page=1

然后你会使用

RewriteCond %{QUERY_STRING} flag=parameter&page=(\d+)
RewriteRule ^/tagged.php$ /parameter/?page=%1

,但我怀疑你实际上想反其道而行之,在这种情况下你会使用

RewriteCond %{QUERY_STRING} page=(\d+)
RewriteRule ^/parameter/$ /tagged.php?flag=parameter&page=%1

Not确定“辣妹”这个词是从哪里来的。

According to the documentation, you need to match against the URL path and the query string separately. If this is really your question,

I am trying to rewrite

tagged.php?flag=parameter&page=1

into

/parameter/?page=1

then you'd use

RewriteCond %{QUERY_STRING} flag=parameter&page=(\d+)
RewriteRule ^/tagged.php$ /parameter/?page=%1

but I suspect you actually want to go the other way around, in which case you'd use

RewriteCond %{QUERY_STRING} page=(\d+)
RewriteRule ^/parameter/$ /tagged.php?flag=parameter&page=%1

Not sure where the "Hotties" thing comes into it.

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