我的网站有动态网页,例如
http://www.example.com/detailpage.php?sn=1%20&&%20database=news
http://www.example.com/detailpage.php?sn=1%20&&%20database=article
http://www.example.com/detailpage.php?sn=1%20&&%20database=interview
以及其他许多
我想从url中删除或隐藏查询字符串变量并显示为
http://www.krishisansar.com/detailpage/news/1
http://www.krishisansar.com/detailpage/article/1
是否可以将查询字符串更改为斜杠?如果没有,如何删除&并制作
/news=1 or /news=2,
/article=1 or /article=2 .
通过这个,我可以从w3c验证。
答案 0 :(得分:2)
您可以在DOCUMENT_ROOT/.htaccess
文件中使用此代码:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /detailpage\.php\?sn=([^\s&]+)&database=([^\s&]+) [NC]
RewriteRule ^ detailpage/%2/%1? [R=302,L,NE]
RewriteRule ^detailpage/(\w+)/(\d+)/?$ detailpage.php?sn=$2&database=$1 [L,QSA,NC]