2

I'm new with but have been studying .htaccess mod_rewrite for the last few days and I'm just finally wrapping my head around it. I was wondering if it was possible to have a simple check to see if a query string equals something specific.. for example:

#First check
RewriteCond $1 !^(img|font|js|css|scripts) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

#if $2 is upgrade, use this ReWrite
RewriteCond %{QUERY_STRING} $2=upgrade
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&subpage=upgrade&tool=$2 [QSA,L]

#If not found... Use this regular ReWrite
RewriteCond $1 !^(img|font|js|css|scripts) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&user=$2 [QSA,L]

I've searched for conditions and such but nothing really turned up a "yes or no" on the possibility of writing such a statement although I've found similar aspects (found on stackoverflow here ) like:

RewriteCond %{QUERY_STRING} (^|&)user=upgrade(&|$) [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&user=upgrade&tool=$2 [L]

Couldn't get it to work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.