index.php url need to hide from homepage of php website

89 views Asked by At

The website www.indowesterncaterers.com/ has menu in header.php

    <ul>

        <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'index.php'){echo 'active'; }else { echo ''; } ?>"><a href="index.php">Home</a></li>
        <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'about-us.php'){echo 'active'; }else { echo ''; } ?>"><a href="about-us.php">About US</a></li>
        <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'plan-your-wedding.php'){echo 'active'; }else { echo ''; } ?>"><a href="plan-your-wedding.php">PLAN YOUR WEDDING</a>

<ul>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'venues.php'){echo 'active'; }else { echo ''; } ?>"><a href="venues.php">venues</a></li>
      <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'invitations.php'){echo 'active'; }else { echo ''; } ?>"><a href="invitations.php">Invitations</a></li>
     <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'flower-decoration.php'){echo 'active'; }else { echo ''; } ?>"><a href="flower-decoration.php">flower decoration</a></li>
      <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'mehandi-function.php'){echo 'active'; }else { echo ''; } ?>"><a href="mehandi-function.php">mehandi function</a></li>

    </ul>


</li>
        <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'wedding-catering.php'){echo 'active'; }else { echo ''; } ?>"><a href="wedding-catering.php">wedding catering</a></li>
        <li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'image-gallery.php'){echo 'active'; }else { echo ''; } ?>"><a href="image-gallery.php">Image Gallery</a></li>
<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'special-offer.php'){echo 'active'; }else { echo ''; } ?>"><a href="special-offer.php">special offer</a></li>
    </ul>

from other pages , like http://www.indowesterncaterers.com/wedding-catering.php

If I click on homepage , the url shows http://www.indowesterncaterers.com/index.php

I want to hide index.php url when clicked from other navigation urls.

The site in core PHP ,

2

There are 2 answers

2
RiggsFolly On BEST ANSWER

Instead of using

<a href="index.php">Home</a>

try

<a href="/">Home</a>
0
user2182349 On

Assuming DirectoryIndex is set to index.php, you should be able to use -

<li class="<?php if(basename($_SERVER['SCRIPT_NAME']) == 'index.php'){echo 'active'; }else { echo ''; } ?>"><a href="/">Home</a></li>