php url rewrite for form GET variables

598 views Asked by At

i did make a rewrite URL in codeigniter fashion, basically i do write url with this schema

my domain / model / controller / varname / varvalue / varname / varvalue

http://mydomain.com/news/detail/idnews/2/myothervar/4/

and i use tho .htaccess

Options +FollowSymlinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [QSA,L]

the problem is that form get value are add as query string instead i would like to be queued as previous var like this

http://mydomain.com/news/detail/idnews/2/myothervar/4/get1/abc/get2/123/
1

There are 1 answers

1
Jon Lin On

Try adding this right after the RewriteBase /:

RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\?[^\ ]+
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /$1 [L,R]

RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\?[^\ ]+
RewriteCond %{QUERY_STRING} ^([^=]+)=([^&]+)
RewriteRule ^(.*?)/?$ /$1/%1/%2/ [L]