PHP Mod_Rewrite

发布于 2024-09-13 18:03:21 字数 182 浏览 2 评论 0原文

我正在尝试使用 mod_rewrite 来实现以下重写:

从 - http:// pre.domain.com/public/?project=Awesome

到 - http:// pre.domain.com/project/Awesome

似乎无法找出答案(尽管浏览了无数的网站)。有什么帮助吗?

I'm trying to use mod_rewrite to achieve the following rewrite:

From - http:// pre.domain.com/public/?project=Awesome

To - http:// pre.domain.com/project/Awesome

Can't seem to figure it out (despite reading through endless sites). Any help?

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

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

发布评论

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

评论(3

猫七 2024-09-20 18:03:21
RewriteEngine On
RewriteRule ^project/(.*) /public/?$1 [L,NC]
RewriteEngine On
RewriteRule ^project/(.*) /public/?$1 [L,NC]
暮色兮凉城 2024-09-20 18:03:21
RewriteEngine On
RewriteCond  %{QUERY_STRING}   ^project=(.*)$
RewriteRule   ^/public/         /project/%1/? [R,L] # strip off query string

您需要使用 RewriteCond 来匹配查询字符串。

RewriteEngine On
RewriteCond  %{QUERY_STRING}   ^project=(.*)$
RewriteRule   ^/public/         /project/%1/? [R,L] # strip off query string

You need to match against the query string using a RewriteCond.

勿挽旧人 2024-09-20 18:03:21

不确定您的网址是否正确,所以我认为您正在尝试这样做:

RewriteRule ^project/(Awesome) /public/?project=$1 [L]

Not sure you have your URLs around the right way so I think your are trying to do this:

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