apache - RewriteRule / RewriteCond help when two "keywords" show in the one query string -


currently have in .htaccess file:

<ifmodule mod_rewrite.c> options -multiviews rewriteengine on rewritebase /forum/ rewritecond %{request_filename} !-f rewriterule \.(jpeg|jpg|gif|png)$ /forum/public/404.php [nc,l]  rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=register(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/register.php? [nc,l,r=302]  rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=login(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/login.php? [nc,l,r=302]  rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=lostpass(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/retrieve_password.php? [nc,l,r=302]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /forum/index.php [l] </ifmodule> 

the 1 need one:

rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=login(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/login.php? [nc,l,r=302] 

currently redirect like:

http://www.mysite.com/forum/index.php?app=core&module=global&section=login 

the &module=global isn't required i'm sure can tell looks app & section parameters.

however problem is, redirects logout link want redirect somewhere else contains app=core & &section=login.

here example:

http://www.mysite.com/forum/index.php?app=coree&module=global&section=login&do=logout&k=xxxxxxxxxxxxxxxxxxx 

so login should still redirect above unless has &do=logout in query string; in case want redirect somewhere else.

how can go doing this?

change rule to:

rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=login(?:&|$) [nc] rewritecond %{query_string} !(?:^|&)do=logout(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/login.php? [nc,l,r=302] 

here rewritecond %{query_string} !(?:^|&)do=logout(?:&|$) [nc] skip redirect if &do=logout present in query string.

edit: per comments:

rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=login(?:&|$) [nc] rewritecond %{query_string} (?:^|&)do=logout(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/logout.php? [nc,l,r=302] 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -