2011-03-02 37 views
0

我已经尝试过,并试图通过我的htaccess知识不是很好,我找不到任何适合我的需求(但后来我不知道我在寻找什么对于)。简单的htaccess国防部重写与可能的查询字符串

有效,我的问题是双重的:

我想转换:http://subdomain.domain.com/hello
要:http://subdomain.domain.com/index.php?string=hello

但偶尔也有可能是一个查询字符串,以及如此...
来源:http://subdomain.domain.com/hello?query=true
要:http://subdomain.domain.com/index.php?string=hello&query=true

到目前为止,我已经管理了第一个:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} -f [NC,OR] 
RewriteCond %{REQUEST_FILENAME} -d [NC] 
RewriteRule .* - [L] 
RewriteRule ^([^/\.]+)/?$ client.php?user=$1&$2 [L] 

请记住,第二个是潜在的:)谢谢!

回答

1

你只需要设置QSA flag的最后一条规则:

RewriteRule ^([^/\.]+)/?$ client.php?user=$1 [L,QSA] 

那么原始请求的查询会自动附加到新的一个。

+0

嗯......它总是最简单的解决方案!谢谢! – Jordan 2011-03-03 00:18:12