I'm using absolute paths to reference assets like css, images and javascript files. So in the <head>
of index.html
I have something like this:
<link href="/assets/css/style.css" rel="stylesheet">
Assuming that my project directory looks like this:
- index.html - assets/ -- css/ --- style.css
This works fine on my local webserver where I set the document root to this directory using a <virtualhost>
directive. But when I put this on a webserver's subdirectory (e.g http://www.example.com/subdirectory/
), it doesn't find the assets anymore when accessing http://www.example.com/subdirectory/index.html
.
How can I solve that without having to use relative paths in index.html
? Can it be achieved with an .htaccess file in the subdirectory? If yes, how?
Edit
There are other folders on the webserver's root level, that shouldn't be affected by any redirect that occurs for /subdirectory/