CSS problem with friendly url

Asked

Viewed 491 times

0

Guys, I’m studying friendly urls and I came across a problem. Every time I put a / (slash) at the end of the url, the css disappears and the page gets pure html. I would like to understand what is happening and tidy up. Follow below the images for better understanding. inserir a descrição da imagem aqui

inserir a descrição da imagem aqui


  • This problem will occur because when you put the bar, the htaccess will treat that string as a folder.

  • got it, in case then every time I link the css I have to do the /meusite/css/file.css?

1 answer

0


The best solution (depending on your application) is to use the tag base HTML5.

<base href="http://seusite.com/" target="_blank">

See an example on w3schools.

Another method is to get the system root folder and play it in a constant. Since you haven’t shown which server side language you’re using, I’ll show you the example in PHP.

<?php

define("ROOT", __DIR__); //obtém pasta root

Dai in your code you use

<img src="<?=ROOT?>/stickman.gif" width="24" height="39" alt="Stickman">

There are still several other examples, but I believe these may be enough to resolve your doubt and help you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.