简体   繁体   中英

URL rewrite with two parameters

I am stuck changing the htaccess file,

currently i am displaying pages like this after rewriting from htaccess:

www.domain.com/contact

which comes to be this url before rewriting from htaccess:

www.domain.com/index.php?show=contact

I am using this code to do the rewriting:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]

    RewriteCond %{THE_REQUEST} \s/+(?:index\.php)?\?show=([^\s&]+) [NC]
    RewriteRule ^ /%1? [R=302,L]

    Header set X-UA-Compatible "IE=Edge,chrome=1"


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?show=$1 [L,QSA]

what i want to do now its set two parameters, eg:

www.domain.com/index.php?show=contact&id=3

which should display:

www.domain.com/contact

and inside that page i wanna be able to get ($_GET['id']) the id.

Please help me i am stuck...

Have a separate rule to handle /contact like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{THE_REQUEST} \s/+(?:index\.php)?\?show=([^\s&]+)&id=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L]

RewriteCond %{THE_REQUEST} \s/+(?:index\.php)?\?show=([^\s&]+)\s [NC]
RewriteRule ^ /%1? [R=302,L]

Header set X-UA-Compatible "IE=Edge,chrome=1"

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([0-9]+)/?$ index.php?show=$1&id=$2 [L,QSA]

RewriteRule ^([^/]+)/?$ index.php?show=$1 [L,QSA]

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