如何使用重写规则替换.php
wth/
例如:
search.php?k=background
至 search/?k=background
到目前为止,我所拥有的是:
RewriteRule ^search/?k=([a-zA-Z0-9_-]+)$ search.php/?k=$1
如何使用重写规则替换.php
wth/
例如:
search.php?k=background
至 search/?k=background
到目前为止,我所拥有的是:
RewriteRule ^search/?k=([a-zA-Z0-9_-]+)$ search.php/?k=$1
这是另一种选择:
RewriteEngine On
RewriteBase /
#Rule applies only when the script is search.php
RewriteCond %{REQUEST_URI} ^.*search\.php.*$
#Query will be automatically appended to search/
RewriteRule .* http://mydomain.com/search/ [L]
将重定向:
http://mydomain.com/search.php?k=background
至
http://mydomain.com/search/?k=background
尝试这个:
RewriteRule ^(.*)\.php(.*)$ $1/$2
您需要从重写规则中删除查询字符串,该规则会自动附加:
RewriteRule ^search/?$ search.php [L]