删除“索引”来自网址
我目前正在将 URL 重写如下:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ articles.php?article=$2
这允许我根据当前执行的页面编写如下链接。
www.example.com/blog/new-article
www.example.com/gallery/new-gallery
因此,当在主页上执行时,这也会导致以下结果:
www.example.com/index/new-post
我希望只有其中包含“index”的 URL 才能在没有它的情况下被重写,例如:
www.example.com/index/new-post -> www.example.com/new-post
这可以完成吗?预先感谢各位!
I am currently re-writing URL's as the following:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ articles.php?article=$2
This allows me to write links such as the following, depending on the currently executing page.
www.example.com/blog/new-article
www.example.com/gallery/new-gallery
So therefore this also results in the following, when executed on the homepage:
www.example.com/index/new-post
I would like it so that only the URLs with 'index' in them, get rewritten without it, such as:
www.example.com/index/new-post -> www.example.com/new-post
Can this be done? Thanks in advance guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在其他规则之前添加此规则:
Add this before your other rules: