How to work with absolute URL?

1

I am developing a system and to perform the tests I am using xampp. That is, everything is accessible through the address:

  

localhost / myite /...

To call all the links on my site, as well as include files, I'm using absolute url, for example:

  

"localhost / nomedosite / pagina1.php"
  "localhost / nomedosite / folder / paginapasta.php"

Everything works perfectly, but now there are more than 50 files that I have developed, the problem with this is that when I perform the hosting, will I have to rewrite each link / include / call of each file? Is there any way I can perform absolute url writing without this bent work?

I thought of using relative urls, but when I do this because of .htacess the urls end up giving error.

    
asked by anonymous 12.08.2017 / 02:22

1 answer

0

Are you programming in PHP right? Then you can create a file called config.php and set it to BASE URL. Example:

<?php
 define('BASE_URL','http:/localhost/nomedosite/'); 

And in the other files you just make the configuration call like this:

<?php
require_once('config.php');
?>
<html ...>
<body>
<a href="<?php  echo BASE_URL; ?>pasta/paginapasta.php">meu link para outro arquivo</a>

Then when you need to change the base just change the settings file config.php .

    
12.08.2017 / 03:01