.htaccess Mod_Rewrite 适用于多种条件

发布于 2024-10-06 19:05:10 字数 506 浏览 0 评论 0原文

我正在努力在域根目录的 .htaccess 文件中重写以下 URL。最好的情况是,我收到 500 服务器错误。

来自:http://sub.example.com/a/?id=1234 至:http://sub.example.com/a/1234

来自:http://sub.example.com/a/b/?id=1234 至:http://sub.example.com/a/1234/b

来自什么我读过它应该相当简单,但我似乎无法做任何事情!

I have the following URLs that I'm struggling to rewrite in the .htaccess file in my domain root. At best, I get a 500 Server Error.

From: http://sub.example.com/a/?id=1234
To: http://sub.example.com/a/1234

From: http://sub.example.com/a/b/?id=1234
To: http://sub.example.com/a/1234/b

From what I've read it should be fairly straightforward, but I can't seem to get anything to work!

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

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

发布评论

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

评论(1

心在旅行 2024-10-13 19:05:10

试试这个规则:

RewriteRule ^a/([0-9]+)(/.*)?$ /a$2/?id=$1 [NC]

Try this rule:

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