htaccess 将子目录重写到php页面
我已经成功重写,
RewriteRule ^alphabetical alpha.php
以便当任何人访问 www.example.com/alphabetical 时它都会加载 alpha.php。但是,我在创建规则时遇到问题,以便当有人访问 www.example.com/alphabetical/a 时,它应该 loa alpha-a.php。这是我尝试过的规则,但不起作用:
RewriteRule ^alphabetical/a alpha-a.php
I've successfully rewritten
RewriteRule ^alphabetical alpha.php
So that when anyone comes to www.example.com/alphabetical it loads alpha.php. However, I'm having problems creating a rule so that when someone comes to www.example.com/alphabetical/a it should loa alpha-a.php. This is the rule I've tried that isn't working:
RewriteRule ^alphabetical/a alpha-a.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将第二个更具体的规则放在第一个规则之上。
RewriteRule ^按字母顺序/a alpha-a.php
RewriteRule ^alphabetical alpha.php
进一步,您可以在末尾使用 $ 来表示 url 的结束,表示以 'a' 结尾的 url。
put your second more specific rule on top of the the first rule.
RewriteRule ^alphabetical/a alpha-a.php
RewriteRule ^alphabetical alpha.php
further, you can use a $ at the end to denote an end of url, saying urls ending with 'a'.