1

如何使用重写规则替换.phpwth/

例如:

search.php?k=backgroundsearch/?k=background

到目前为止,我所拥有的是:

RewriteRule ^search/?k=([a-zA-Z0-9_-]+)$ search.php/?k=$1
4

3 回答 3

2

这是另一种选择:

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

于 2012-12-09T22:57:03.707 回答
1

尝试这个:

RewriteRule ^(.*)\.php(.*)$ $1/$2
于 2012-12-09T22:24:25.470 回答
1

您需要从重写规则中删除查询字符串,该规则会自动附加:

RewriteRule ^search/?$ search.php [L]
于 2012-12-10T03:08:51.293 回答