Reputation: 51
I have a php file containing my navbar(menu.php) which is used from many of my pages. Let me show you my folder structure:
index.php
html
menu.php
apps
app1.php
app2.php
webdesign
html.php
js.php
and the following code: <
div class="navbar navbar-inverse navbar-static-top navbar-topic">
<div class="container">
<div class="navbar-header"><!--navbar start-->
<a href="http://kounj.web44.net" class="navbar-brand"><!--Logo -->
iloveprogramming
</a>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span><!--4 icon-bar spans create the dropdown menu-->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Web Design <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="/webdesign/html.php">Html</a></li>
<li><a href="/webdesign/css.php">Css</a></li>
<li><a href="/webdesign/js.php">Javascript</a></li>
<li><a href="/webdesign/php.php">PHP</a></li>
</ul>
</li>
<li><a href="/apps/index.php">Tools</a></li>
<li><a href="/contact.html">Contact</a></li>
</ul>
</div>
</div>
</div><!--navbar end-->
The problem is that when i use index.php which is on the root folder my links on navbar will not be set correctly.Any ideas
Upvotes: 1
Views: 83
Reputation: 2230
You can either use absolute path by setting a constant in menu.php that might look like this:
define("ROOTPATH", "/var/www/html/apps/");
(A quick and dirty approach, but effective) for your Navigation links and setting them like so:
<a href="<?php echo ROOTPATH; ?>/app1.php</a>
<!-- etc -->
Or you can edit you Apache http.conf file thereby pointing it to your PHP projects root folder, and restart apache to get your changes to take effect. But both will address your PHP file path issues.
Upvotes: 1