When I visit my website with the unfriendly URL everything is shown to me fine without problems, but when I visit my site with the friendly URL it works but it seems that the routes within the pages are incorrect and this happens:
When I pass the cursor over any link, it shows me an incorrect route, for example, thecanario/article/3/login
when it really should be, thecanario/login
but when I enter with the ugly url that is not friendly, everything is shown correctly and I cannot figure out where the problem is. .
.htaccess file
# Eliminar el .php en todos los archivos
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# URL Amigable
RewriteRule ^article/([0-9]+) article.php?id=$1&title=$2
# Error 404
ErrorDocument 404 http://localhost/thecanario/404
Link where I create my URL:
<a href="article/<?=$id_more_post?>/<?=$titleMoreURL?>">
If you think I should display other information that I may be forgetting, just let me know.
Your error is something simple to resorb and there are several ways. One that you can do but that I do not recommend is that you put the full URL to your links and scripts, either by copying the url in the browser and pasting it completely, that would eliminate your problem.
The next thing you can do and that I recommend is to place the html5
<head>
tag under the title of your page and there you specify only the domain of your url<base>
Example:
Remember that you can perfectly put your local host address, for example
And it wasn't a problem either.
With doing that, it would be ready and in your file everything would work perfectly
I use this methodology, maybe it will help you.
directory
First I prepare the index.php
.htaccess
Example page1 to take the values passed by URL
You could try something like this to do what you want
Note: 'id' is the name of your get variable ($_GET["id"])
I have achieved what you want, putting your .htaccess and index inside an article folder and in the htaccess the following code