我有 index.php 页&有一些帖子。当点击更多按钮被点击时,用户被重定向到 all.php ,其中包含完整的帖子。实际上, all.php 上的网址就像这样
http://localhost/project/all.php?rm=How%20to%20create%20jQuery%20Popup
我想将%20
更改为-
。
无论如何用 htaccess 来做到这一点。?
答案 0 :(得分:0)
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one (remove query string)
RewriteCond %{THE_REQUEST} \s/+content\.php\?page=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L,NE]
# convert all space (%20) to hyphen
RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [N,NE]
RewriteRule "^(\S*) (\S*)$" $1-$2 [L,R=302,NE]
# rewrite rule to call actual PHP handler
RewriteRule ^([^./]+)\.html$ content.php?page=$1 [L,QSA,NC]