我想mod_rewrite一个URL到另一个页面,但我还希望保留任何添加的查询字符串.
RewriteEngine On
#enforce trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !#
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://localhost/siteroot/$1/ [L,R=301]
RewriteRule ^apps/([A-Za-z0-9-_]+)/?$ index.php&app=$1
Run Code Online (Sandbox Code Playgroud)
因此,如果用户访问apps/app1/,index.php?app=app1则显示.但是,我希望能够保留可选的查询字符串,以便访问apps/app1/?variable=x返回index.php?app=app1&variable=x.
什么mod_rewrite规则/条件会使这种情况发生?