apache - .htacess Query String ? Instead of & -


in website want rewrite urls from

http://myexampledomain.com/index.php?page=about

to

http://myexampledomain.com/about

so, in order achieve did fix .htaccess code like

rewriteengine on rewriterule ^([^/]*)$ index.php?page=$1 [l] rewriterule ^api/([^/]*)$ api/$1 [l] 

now, problem when need send query string page urls need like

http://myexampledomain.com/about&myquery1=value&myquery2=value

i should start &myquery1=value&myquery2=value instead of ?myquery1=value&myquery2=value because first ? been used in .htaccess.

but now, need fixed , should able access domain like

http://myexampledomain.com/about?myquery1=value&myquery2=value

how can fix this??

you need add qsa flag in rule:

rewriteengine on  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/]+)/?$ index.php?page=$1 [l,qsa] 

qsa (query string append) flag preserves existing query parameters while adding new one.


Comments