Title: $_SERVER[’SCRIPT_NAME’ issues
Last modified: August 18, 2016

---

# $_SERVER[’SCRIPT_NAME’ issues

 *  Resolved [neilscott](https://wordpress.org/support/users/neilscott/)
 * (@neilscott)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/_serverscript_name-issues/)
 * Hello,
 * I am trying to combine dynamic menus (described so well in the codex) with another
   level of functionality that involves specifying a different php file for each
   top level page (which contain the subpages). Sounds complicated, well here’s 
   an example of how it should look: [http://www.bipcorporate.com](http://www.bipcorporate.com)
 * What I don’t seem to be able to work out is how to specify a specific php rule.
   This is what I’ve worked out so far:
    ` <?php if ($_SERVER[’SCRIPT_NAME’]='/about'){
   include( TEMPLATEPATH . '/nav/about.php'); }  elseif ($_SERVER[’SCRIPT_NAME’]
   ='/contact') { include( TEMPLATEPATH . '/nav/contact.php'); }  else { include(
   TEMPLATEPATH . '/nav/home.php'); }  ?>
 * But it doesn’t work.
 * Any ideas?
 * Thanks,
 * Neil

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

 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [19 years, 3 months ago](https://wordpress.org/support/topic/_serverscript_name-issues/#post-520632)
 * i’d try using $_SERVER[“REQUEST_URI”] instead of $_SERVER[‘SCRIPT_NAME’].
 * But how does it not work exactly? Does it allways show home.php?
 * D
 *  Thread Starter [neilscott](https://wordpress.org/support/users/neilscott/)
 * (@neilscott)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/_serverscript_name-issues/#post-520633)
 * Okay, I managed to sort it out, here is the solution:
 *     ```
       <?php
   
         if(stristr($_SERVER['REQUEST_URI'], '/about')){
                include( TEMPLATEPATH . '/nav/about.php');
         }elseif(stristr($_SERVER['REQUEST_URI'], '/brands')){
                include( TEMPLATEPATH . '/nav/contact.php');
         }elseif(stristr($_SERVER['REQUEST_URI'], '/investor')){
                include( TEMPLATEPATH . '/nav/contact.php');
         }elseif(stristr($_SERVER['REQUEST_URI'], '/careers')){
                include( TEMPLATEPATH . '/nav/contact.php');
         }elseif(stristr($_SERVER['REQUEST_URI'], '/media')){
                include( TEMPLATEPATH . '/nav/contact.php');
         }elseif(stristr($_SERVER['REQUEST_URI'], '/contact')){
                include( TEMPLATEPATH . '/nav/contact.php');
         }else{
                include( TEMPLATEPATH . '/nav/home.php');
         } 
   
       ?>
       ```
   

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

The topic ‘$_SERVER[’SCRIPT_NAME’ issues’ is closed to new replies.

## Tags

 * [if](https://wordpress.org/support/topic-tag/if/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [neilscott](https://wordpress.org/support/users/neilscott/)
 * Last activity: [19 years, 3 months ago](https://wordpress.org/support/topic/_serverscript_name-issues/#post-520633)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
