简体   繁体   中英

Apache mod_rewrite - Query String not appending

I have a URL that i want to rewrite but want to keep the Query String as it is. I tried several options but not working.

http://www.example.com/images/cam?fileName=123.jpg&format=jpeg I want this to rewrite to http://www.example.com/new-images/cam?fileName=123.jpg&format=jpeg

I am using following rewrite rule

RewriteRule ^images/cam(.*)$ /new-images/cam$1 [L]

What am i missing. Thanks in advance.

You can use:

RewriteRule ^images/(cam/?)$ new-images/$1 [L,NC]

QUERY_STRING will be automatically carried over to new target URI.

You can set the QSA flag to append the original query string to the rewrite:

RewriteRule ^images/cam(.*)$ /new-images/cam$1 [L,QSA]

(see: http://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_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