简体   繁体   中英

URL rewrite rules not working

current URL

http://mywebsite.com/explore.php?location=india&search_query=about&filter[]=v

Desired URL

http://mywebsite.com/explore/india/about/v

Rules used:

RewriteRule ^explore/([^/]*)/([^/]*)/([^/]*)$ /explore.php?location=$1&search_query=$2&filter[]=$3 [L]

You forgot to specify that your words can be more than one character. I think you need something more like :

RewriteEngine on
RewriteRule ^explore/([^/]*)/([^/]*)/([^/]*)$ /explore.php?location=$1&search_query=$2&filter[]=$3 [L]

With

http://mywebsite.com/explore/india/about/v

if you output $_GET in explore.php , you would get :

array(3) { 
    ["location"]=> string(5) "india" 
    ["search_query"]=> string(5) "about" 
    ["filter"]=> array(1) { 
        [0]=> string(6) "v" 
    } 
} 

Your actual RewriteRule worked for something like :

http://mywebsite.com/explore/i/a/v

Hope it helps

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