简体   繁体   English

使用.htaccess重定向获取参数

[英]Redirect Get-Parameter with .htaccess

I will redirect this url, with help from .htaccess: 我将在.htaccess的帮助下重定向此URL:

http://www.example.com/index.php?q=where is new york?&start=0&type=web

to: 至:

http://www.example.com/search/where is new york?/0/web

knows anybody how i can implement this plan ? 知道有人我可以执行这个计划吗? importend is, that the question mark don't reset the other GET-Value. 重要的是,问号不要重置其他GET-Value。 Thanks! 谢谢!

Have it this way in your root .htaccess: 以这种方式在您的根.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

For the querystring you need to use a condition. 对于querystring,您需要使用条件。 Further help can be found here 可以在这里找到更多帮助

If you want to rewrite the url: 如果要重写URL:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?q=$1&start=$2&type=$3 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM