mod_rewrite 仅特定网址

发布于 2024-10-05 07:10:35 字数 621 浏览 0 评论 0原文

mod_rewrite 是我最大的敌人,我一生都无法弄清楚出了什么问题,所以废弃了我拥有的所有 htaccess 内容,希望你们这些聪明的傻瓜可以帮助一个愚蠢的傻瓜!

我们只想重写 3 个链接,因此它只会影响这些链接。

index.php?portfolio=print

portfolio/print

然而

index.php?portfolio=branding

希望它影响

portfolio/branding

我不

index.php?portfolio=illustration]

链接

portfolio/illustration

像index.php?portfolio=photography这样的

所以理想情况下我猜 3 行有 3 条规则,只重写那些链接,基本目录是 /new/。

希望你们能帮忙:)

再次感谢!

欧文

mod_rewrite is my worst enemy and cant for the life of me figure out whats going wrong, so scrapped any htaccess content i had in hope you clever fools can help a dumb fool!

we only want 3 links re-written so it only effects these.

index.php?portfolio=print

into

portfolio/print

and

index.php?portfolio=branding

into

portfolio/branding

and

index.php?portfolio=illustration]

into

portfolio/illustration

however i dont want it to effect links such as index.php?portfolio=photography.

so ideally i guess 3 lines with 3 rules that re-write only those links, the base dir is /new/.

hope ya guys can help :)

thanks again!

Owen

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

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

发布评论

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

评论(1

意中人 2024-10-12 07:10:35
RewriteRule ^portfolio/(print|branding|illustration)$ index.php?portfolio=$1 [L]

这将与您使用具有2个假设的一条规则所描述的内容相匹配 - 没有尾随斜杠或查询字符串参数。

如果您希望在 URL 中出现任何一个,请评论回来。您可以通过将其附加到捕获来非常轻松地添加另一个部分。

RewriteRule ^portfolio/(print|branding|illustration)$ index.php?portfolio=$1 [L]

This will match what you describe using one rule with 2 assumptions - no trailing slash or query string parameters.

Comment back if you expect either in the URLs. You can add another section very easily by appending it to the capture.

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