0

我想?s=/search/..htaccess

示例:http://hello.com/?s=hey=>http://hello.com/search/hey

我怎样才能做到这一点?

4

3 回答 3

0

感谢大家的回答,这对我有用,取自这里

RewriteCond %{QUERY_STRING} s=(.*)
RewriteRule ^$ /search/%1? [R,L]
于 2012-04-16T20:08:07.027 回答
0

可能是这样的

RewriteEngine On
RewriteRule ^search/(.*)  index.php?s=$1     [QSA,L]

这样,您将访问您的网站,例如

http://hello.com/search/hey将被解释为http://hello.com/index.php?s=hey

希望这可以帮助

于 2012-04-16T19:31:20.253 回答
0

将此代码放在 DOCUMENT_ROOT 下的 .htaccess 中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# external redirect from index.php?s=key to search/key
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?s=([^\s]+) [NC]
RewriteRule ^ search/%1? [L,R,NC]

# external redirect from search/key to index.php?s=key
RewriteRule ^search/(.+)$ index.php?s=$1 [L,NC,QSA]
于 2012-04-16T19:55:46.647 回答