mod_rewrite {QUERY_STRING}

发布于 2024-09-27 18:25:38 字数 613 浏览 0 评论 0原文

我确信这个问题已经被问过无数次了,但我无法让它发挥作用, 我正在尝试用查询字符串重写一个网址,我的网址例如:

http://example.com/articles/index.php?keyword=book

并且我希望可以通过

http://example.com/articles/keyword/book/

谷歌访问它,但我没有任何运气, 我走在正确的轨道上吗?我得到这个:

RewriteCond %{QUERY_STRING}     ^keyword=(.*)$    [NC]
RewriteRule ^/articles/index.php$         /articles/keyword/$1          [NC,L,R=301]

更新

这工作正常

RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteRule ^.*/(\w+)\b$ /articles/index.php?keyword=$1

I'm sure that's been asked zillions times but i can't get it to work,
i'm trying to rewrite a url with querystring, my url is for example:

http://example.com/articles/index.php?keyword=book

and i want to be accessible from

http://example.com/articles/keyword/book/

I google it and i didn't have any luck,
am i on the right track? i got this:

RewriteCond %{QUERY_STRING}     ^keyword=(.*)$    [NC]
RewriteRule ^/articles/index.php$         /articles/keyword/$1          [NC,L,R=301]

UPDATE

this is working fine

RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteRule ^.*/(\w+)\b$ /articles/index.php?keyword=$1

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

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

发布评论

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

评论(1

也只是曾经 2024-10-04 18:25:38

它应该可以工作:

RewriteRule ^articles/keyword/(.*)/?$ index.php?keyword=$1

如果没有,请告诉我;)

It should work:

RewriteRule ^articles/keyword/(.*)/?$ index.php?keyword=$1

If not, please tell me ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文