URL重写字
我有一个相当简单的问题,我无法弄清楚。
这是我的 .htaccess 规则:
RewriteRule ^articles/([a-zA-Z0-9_-]+)/?$ articles.php?article=$1
这会产生 URL,例如 www.example.com/articles/article-name 我想要的是将规则中的“文章”更改为当前 URL 的名称。
例如来自:
www.example.com/articles/article-name
至:
www.example.com/blog/article-name
www.example.com/gallery/article-name
我目前正在编写链接为:
<a href="articles/$articleName">
我已将其更改为以下内容,但无法让 .htaccess 使用它:
<a href="$pageNoExtension/$articleName">
提前致谢,新年快乐!
I have a fairly simple problem which I can't figure out.
Here is my .htaccess rule:
RewriteRule ^articles/([a-zA-Z0-9_-]+)/?$ articles.php?article=$1
This results in URL's such as www.example.com/articles/article-name
What I'd like is to change the 'articles' in the rule, to the name of the current URL.
For example from:
www.example.com/articles/article-name
To:
www.example.com/blog/article-name
www.example.com/gallery/article-name
I am currently writing links as:
<a href="articles/$articleName">
I have changed it to the following, but can't get the .htaccess working with it:
<a href="$pageNoExtension/$articleName">
Thanks in advance and happy new year!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也祝你新年快乐:)
Happy new year to you too :)