html <base> doesn't work with href to localhost

Paweł Bąkiewicz picture Paweł Bąkiewicz · Feb 8, 2014 · Viewed 15.4k times · Source

My links look like

<link rel="stylesheet" href="/utils/style.css" />

I had my website in main dir so it wasn't a problem but when I moved all my files to /dir/ I set up base tag :

<base href="http://localhost/dir" />

But it doesn't work. It works perfectly fine though if I use online URL to my website

<base href="http://www.my-website.com" />

what's wrong ?

Answer

user3287764 picture user3287764 · Feb 8, 2014

Dir is a directory therefore you need to add a / after it, also you don't need to use base to have clean URL's... If that's what your trying to do.

<base href="http://localhost/dir/" />