[英]Redirect Get-Parameter with .htaccess
我将在.htaccess的帮助下重定向此URL:
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
知道有人我可以执行这个计划吗? 重要的是,问号不要重置其他GET-Value。 谢谢!
以这种方式在您的根.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]
RewriteCond %{QUERY_STRING} q=(.*)&start=(.*)&type=(.*)
RewriteRule /index\.php search/%1?/%2/%3
对于querystring,您需要使用条件。 可以在这里找到更多帮助
如果要重写URL:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?q=$1&start=$2&type=$3 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.