小编Dan*_*key的帖子

我如何mod_rewrite和保持查询字符串?

我想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规则/条件会使这种情况发生?

apache .htaccess mod-rewrite query-string

27
推荐指数
1
解决办法
3万
查看次数

标签 统计

.htaccess ×1

apache ×1

mod-rewrite ×1

query-string ×1