2012-10-17 93 views
0

設置.htaccess似乎對這種情況很困難。對於一個交友網站,我們有這樣的場景:.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 

基本上,我需要的.htaccess知道立即?意味着不使用上述重寫規則。任何想法如何做到這一點?

回答

1

嘗試:

RewriteCond %{QUERY_STRING} askout=yes&when=later 
RewriteRule^/profiles.php?askout=yes&when=later [L] 

此規則需要去之前,您已經重定向到該規則?username目標。

相關問題