Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess-If/Else根据查询字符串重定向_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

.htaccess-If/Else根据查询字符串重定向

.htaccess-If/Else根据查询字符串重定向,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,在这种情况下,设置.htaccess似乎很困难。对于交友网站,我们有以下场景: We assume john is logged in: domain.com/john //this works no problem domain.com/?askout=yes&when=later //this doesn't work, if john is logged in and pastes this url, i

在这种情况下,设置.htaccess似乎很困难。对于交友网站,我们有以下场景:

We assume john is logged in:

domain.com/john //this works no problem

domain.com/?askout=yes&when=later //this doesn't work, if john is logged in and pastes 
                                    this url, it automatically redirects to domain.com/john
                                    instead, htaccess should see the ? and know it's
                                    not a valid user. It should keep the entire query,
                                    and redirect to /profiles.php?askout=yes&when=later
以下是.htaccess:

RewriteRule ^(\w+)/?$ ./profiles.php?username=$1

基本上,我需要有。知道吗?表示不使用上述重写规则。你知道如何做到这一点吗?

我想你需要一个重写条件:,用它你可以做各种检查

试试:

RewriteCond %{QUERY_STRING} askout=yes&when=later
RewriteRule ^ /profiles.php?askout=yes&when=later [L]
此规则需要在重定向到
?用户名
目标的规则之前执行