index.php url需要隐藏在php网站的主页上

时间:2015-06-09 11:31:39

标签: php url

网站www.indowesterncaterers.com/在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>

来自其他网页,例如http://www.indowesterncaterers.com/wedding-catering.php

如果我点击主页,则网址会显示http://www.indowesterncaterers.com/index.php

我想在从其他导航网址点击时隐藏index.php网址。

PHP核心网站

2 个答案:

答案 0 :(得分:1)

而不是使用

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

尝试

<a href="/">Home</a>

答案 1 :(得分:0)

假设DirectoryIndex设置为index.php,您应该可以使用 -

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