How can I mod_rewrite and keep query strings?

后端 未结 1 1304
无人共我
无人共我 2020-11-29 12:53

I want to mod_rewrite a URL to another page, but then I also want any query strings added to be preserved.

RewriteEngine On

#enforce trailing slashes
Rewrit         


        
相关标签:
1条回答
  • 2020-11-29 13:44

    You need to add the [QSA] flag ("query string append")

    RewriteRule ^apps/([A-Za-z0-9-_]+)/?$ index.php&app=$1 [L,QSA]
    

    For page 301 redirects with the [R] flag as opposed to internal rewrites like this one, the query string is automatically appended. However, you must force it with [QSA] for the internal rewrite.

    0 讨论(0)
提交回复
热议问题