htaccess URL 重写的正则表达式
hiii ,
我想重写目录 www.mysite.com/index.php?category=news 访问 www.mysite.com/news 我写了这段代码,但它不起作用 任何人都可以帮忙,拜托 感谢您的帮助
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ index.php?category=$1
感谢所有回答我问题的人,当我尝试编写 www.mysite.com/news 时,所有代码都可以工作,但我的意思是当我单击链接时 "a href='index.php?category=news'"link"/a" 我想立即重写到 www.mysite.com/news
hiii ,
I want to rewrite the directory www.mysite.com/index.php?category=news
to www.mysite.com/news
I write this code but its doesn't work
anyone can help, please
thanks for help
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ index.php?category=$1
Thanks for all who answered my question , all the codes are work when i try to write www.mysite.com/news , but I mean when i click on a link
"a href='index.php?category=news'"link"/a" I want to be rewrite to www.mysite.com/news immediately
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只是为了确认一下,您想要匹配的模式是所有字母、数字、连字符和正斜杠,对吧?
如果是这样,请尝试这个,
我认为问题可能是您在字符类表达式中对连字符和正斜杠的排序。要匹配连字符,它们应出现在字符集中的第一个或最后一个。
Just to confirm, the pattern you want to match is all letters, numbers, hyphens and forward-slashes, right?
If so, try this
I think the problem may have been your ordering of the hyphen and forward-slash in the character class expression. To match hyphens, they should appear first or last in the set of characters.
这有效吗?
Does this work?
试试这个
try this