简体   繁体   中英

Redirect Get-Parameter with .htaccess

I will redirect this url, with help from .htaccess:

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. Thanks!

Have it this way in your 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]
RewriteCond %{QUERY_STRING} q=(.*)&start=(.*)&type=(.*)
RewriteRule /index\.php search/%1?/%2/%3

For the querystring you need to use a condition. Further help can be found here

If you want to rewrite the url:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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