我想?s=
用/search/
..htaccess
示例:http://hello.com/?s=hey
=>http://hello.com/search/hey
我怎样才能做到这一点?
我想?s=
用/search/
..htaccess
示例:http://hello.com/?s=hey
=>http://hello.com/search/hey
我怎样才能做到这一点?
感谢大家的回答,这对我有用,取自这里。
RewriteCond %{QUERY_STRING} s=(.*)
RewriteRule ^$ /search/%1? [R,L]
可能是这样的
RewriteEngine On
RewriteRule ^search/(.*) index.php?s=$1 [QSA,L]
这样,您将访问您的网站,例如
http://hello.com/search/hey
将被解释为http://hello.com/index.php?s=hey
希望这可以帮助
将此代码放在 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]