使用.htaccess重写不同url的url
我正在尝试在我的网站上使用.htaccess创建干净的URL我有这个使用.htaccess重写不同url的url,.htaccess,mod-rewrite,url-rewriting,friendly-url,bluehost,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,Bluehost,我正在尝试在我的网站上使用.htaccess创建干净的URL我有这个 RewriteEngine on RewriteRule ^([^/]*)/$ /full_posts.php?permalink=$1 [L] RewriteRule ^category/([^/]*)/$ /search.php?category=$1 [L] 第一个工作正常,但第二个不工作,我正在一个接一个地写。请帮忙 您正在寻找的规则是: RewriteRule ^([^/]*)/?$ /full_posts.php
RewriteEngine on
RewriteRule ^([^/]*)/$ /full_posts.php?permalink=$1 [L]
RewriteRule ^category/([^/]*)/$ /search.php?category=$1 [L]
第一个工作正常,但第二个不工作,我正在一个接一个地写。请帮忙 您正在寻找的规则是:
RewriteRule ^([^/]*)/?$ /full_posts.php?permalink=$1 [L]
RewriteRule ^category/([^/]*)/?$ /search.php?category=$1 [L]
我在这两种情况下都做了尾随斜杠
您可以在以下方面测试您的规则:
不工作;怎样?您正在访问哪个页面?显示了什么错误?我现在知道了,我没有在末尾添加斜杠。thankssir,如何将最后一个正斜杠设置为可选的要将尾随斜杠设置为可选的,您可以在它前面加一个问号
RewriteRule^([^/]*)/?$/full_posts.php?permalink=$1[L]
和RewriteRule^ category/([^/]*)/?$/search.php?category=$1[L]
好的,我添加了.html而不是斜杠,我想知道哪一个更好,这取决于你想做什么。我认为.html在网站上没有任何用处。。。这只会让用户更难键入URL。我建议你跳过它!此外,还要尽量与URL保持一致,这样搜索引擎就不会找到重复的内容。使用规范的URL!