I have the following code, which works perfectly for me when I have the files in the same directory level. Over time I have continued to cram things into the web page and have had to create several subdirectory levels, which makes this code no longer work.
I don't use any plugins, is there a way to get my URLs redirected no matter what directory levels my files are in?
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu-principal">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php"><img src="img/home/logo.png" alt="CDCGroup"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu-principal">
<ul class="nav navbar-nav ">
<li class="hidden"><a href="#page-top"></a></li>
<li><a class="page-scroll" href="nosotros.php">Nosotros</a></li>
<li><a class="page-scroll" href="index.php#soluciones">Soluciones</a></li>
<li><a class="page-scroll" href="index.php#capacitacion">Capacitación</a></li>
<li><a class="page-scroll" href="marcas.php">Marcas</a></li>
<li><a class="page-scroll" href="index.php#sucursales">Sucursales</a></li>
<li><a class="page-scroll" href="index.php#contact">Contacto</a></li>
<li><a class="page-scroll" href="promociones.php">Promociones</a></li>
<li class="redes-sociales">
<a class="page-scroll" href="#"><i class="fa fa-twitter"></i></a>
<a class="page-scroll" href="#"><i class="fa fa-facebook"></i></a>
<a class="page-scroll" href="#"><i class="fa fa-youtube-play"></i></a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
Well since you are programming in PHP to create the HTML as I see in the tag you used
php
andphp5
, the recommendation is that you create a route system.For this it is a
array
save the routes with a key to identify them, and with a function you return the URL.Now this file can be included in any page to generate your urls.