Probably not.. but..
I there a way to rewr开发者_JAVA百科ite ?search=
and make it read /news/
in .htaccess
?
So mydomain.com/?search=frogs
would be: mydomain.com/news/frogs
Yes, you need to set a rewrite rule in .htaccess that does an HTTP redirect to cause the browser to request the new URL. I would recommend a 301 (permanent redirect) response code unless this is temporary, in which case use 302.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^search=(.*)$
RewriteRule ^$ /news/%1? [L,R=301]
Should work, although I haven't tested. Here's a good rundown of some of the issues redirecting a URL with a querystring to a URL without one.
EDIT: after testing, changed the first argument of the RewriteRule from ^/$
to ^$
. Should work now for URLs like example.com/?search=foo
.
simples...
RewriteRule ^/news/(.*)$ index.php?search=$1 [NC,L]
精彩评论