我将在.htaccess:
的帮助下重定向此网址http://www.example.com/index.php?q=where is new york?&start=0&type=web
为:
http://www.example.com/search/where is new york?/0/web
知道任何人如何实施这个计划? importend是,问号不会重置其他GET-Value。 谢谢!
答案 0 :(得分:2)
在你的root中以这种方式.htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+index\.php\?q=([^\s&]+)&start=([^\s&]+)&type=([^\s&]+) [NC]
RewriteRule ^ /search/%1/%2/%3? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(search/[^/]+)/?$ /$1\%3F/%{QUERY_STRING}? [L,NC,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/?$ search.php?q=$1&start=$2&type=$3 [L,QSA,NC]
答案 1 :(得分:0)
RewriteCond %{QUERY_STRING} q=(.*)&start=(.*)&type=(.*)
RewriteRule /index\.php search/%1?/%2/%3
对于查询字符串,您需要使用条件。可以找到进一步的帮助here
答案 2 :(得分:0)
如果你想重写网址:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?q=$1&start=$2&type=$3 [L]