.htaccess-If/Else根据查询字符串重定向
在这种情况下,设置.htaccess似乎很困难。对于交友网站,我们有以下场景:.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
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]
此规则需要在重定向到?用户名
目标的规则之前执行