简体   繁体   中英

ReWrite rule for long URL

I am having Rewrite rule ad follow

RewriteEngine On
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteRule ^(.*)/(.*)/?$ index.php?rt=$1/$2  [L]
RewriteRule ^(.*)/(.*)/(.*)/?$ index.php?rt=$1/$2/$3  [L]

if the URL comes like, http://www.example.com/manage/ne/new?query=123 means , i cont get the value of 'query' passed in url using "$_GET" in php .

it redirect like ` http://www.example.com/index.php?rt=manage/ne/new

but my need is http://www.example.com/index.php?rt=manage/ne/new&query=123

can any one help me to fix this issues regarding Htacces.

You need QSA flags in bottom 2 rules:

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

QSA (Query String Append) flag preserves existing query parameters while adding a new one.

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