I explain my problem, it's simple, I've solved it, but only locally, it does not work for me if I use this on a normal server.
I modified my .htaccess for friendly URLs, the issue is that I have problems with file paths ( css , images , js , etc).
Because for example, my route is:
localhost / project / user / pepito /
So, when I link my CSS or images, normally, it gives me this:
I mean, I'm not taking the file path.
I have this PHP code in a file, to use it to be able to have the absolute URL and not have problems (I already share it with you):
$s = $_SERVER['SERVER_NAME'];
$a = explode('/', $_SERVER['PHP_SELF'], 3);
$completeURL = "http://".$s."/".$a[1];
In this way, you would be saving in the variable completeUrl :
link localhost / project
Then, when I'm going to put an image, I would put:
<img src="<?php echo $completeURL; ?>/images/img.png" alt="">
So, if it works, but this in the normal server does not work for me, because it prints me:
So, what I'm looking for, in a way that I can always print the whole route, without having to change all my codes to work on the server. I have too many routes set in the way I already showed, but if for example, I have an image and use:
<img src="<?php echo $completeURL; ?>/images/img.png" alt="">
This would impress me:
It would not make sense. How can I solve this problem?