Title: &lt;?php if($_SERVER[&#8216;QUERY_STRING&#8217;]) : ?&gt;
Last modified: August 18, 2016

---

# <?php if($_SERVER[‘QUERY_STRING’]) : ?>

 *  [mrtagomi](https://wordpress.org/support/users/mrtagomi/)
 * (@mrtagomi)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/ltphp-if_serverquery_string-gt/)
 * I’m using a method suggested by Kafkaesqui of determining whether the adress 
   you’re at is *www.mysite.com/index.php* or *www.mysite.com/whatever* — so I can
   alter my homepage without essentially altering the way every other page/post 
   displays by default. This is what I’m using at the moment and it works great:
 * (this code is in my index.php / ‘mainpage template’)
 * <?php if($_SERVER[‘QUERY_STRING’]) : ?>
    //do stuff <?php else : ?> //do different
   stuff <?php endif: ?>
 * But what I want to know is how I can extend this to
 * 1. first check if browser is at index.php, and if so, do //stuff
    2. check if
   browser is at [http://www.mysite.com/](http://www.mysite.com/)**?cat=***anything*,
   and if so, do //otherstuff 3. else do //normalstuff
 * so my guess would be that I should use a *switch/case* type of function instead
   of *if/else*… how can I do this?
 * btw thanks support volunteers, I’ve found answers to about a dozen questions 
   by searching these forums so far 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [angsuman](https://wordpress.org/support/users/angsuman/)
 * (@angsuman)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/ltphp-if_serverquery_string-gt/#post-221264)
 * Look in codex for these functions
    is_home() is_category() etc.
 * Although I think the meaning is self-evident 🙂
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/ltphp-if_serverquery_string-gt/#post-221300)
 * angusman is referring to this:
 * [http://codex.wordpress.org/Conditional_Tags](http://codex.wordpress.org/Conditional_Tags)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘<?php if($_SERVER[‘QUERY_STRING’]) : ?>’ is closed to new replies.

## Tags

 * [?cat](https://wordpress.org/support/topic-tag/cat/)
 * [case](https://wordpress.org/support/topic-tag/case/)
 * [else](https://wordpress.org/support/topic-tag/else/)
 * [home.php](https://wordpress.org/support/topic-tag/home-php/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [index.php](https://wordpress.org/support/topic-tag/index-php/)
 * [switch](https://wordpress.org/support/topic-tag/switch/)

 * 2 replies
 * 3 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [20 years, 11 months ago](https://wordpress.org/support/topic/ltphp-if_serverquery_string-gt/#post-221300)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
