如何在 htaccess 中拥有不同模式的多个重写规则?
好吧,我有一个 .htaccess 文件,我正在为框架设计工作,我已经在网上搜索并用它进行了三天的实验,我有点恼火。
这是我的约定:
案例 1:www.example.com/id
案例 2:www.example.com/key/id
我想做的是让 url 管理变得容易,对于第一种情况,我会用它来收集页面名称,以防它更像是有人有一个商店,它可以充当密钥并告诉系统查找具有给定 ID 的 id 的商店。我希望这能提供更多澄清。
这是我的 htaccess 定义:
RewriteEngine On
RewriteRule ^(A-Za-z0-9_-]+)/(.*)/?$ index.php?key=$1&id=$2
RewriteRule ^([A-Za-z0-9_-]+)/?$ index.php?id=$1
有人可以告诉我为什么这不起作用或者我该怎么做让它发挥作用吗?
Ok I have a .htaccess file I'm working on for a framework design, I've been searching online and experimenting for three days with it and I'm getting a bit irritated.
Here's my convention:
Case 1: www.example.com/id
Case 2: www.example.com/key/id
What I want to do is make it easy for url managment, for case one I would use that to collect the page name, in case to it would be more like if someone had a store which would act as a key and tell the system to look for a store with the id of the given ID. I hope this gave more clarification.
Here's my htaccess definition:
RewriteEngine On
RewriteRule ^(A-Za-z0-9_-]+)/(.*)/?$ index.php?key=$1&id=$2
RewriteRule ^([A-Za-z0-9_-]+)/?$ index.php?id=$1
Can someone please tell me why this isn't working or how I can get this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加
以查看那里正在重写什么。您可能需要在末尾或 RewriteBase 处使用 [L] 或其他可能错误的内容。 如果您需要更多帮助,请发布价值
。
Add
to see what's being rewritten there. You might need [L] at the end or RewriteBase or something else might be wrong. Post value of
if you need more help.