I have managed to do it with the help of vhost.
For example:
- Code: Select all
<VirtualHost *:80>
ServerName website_1.se
ServerAlias www.website_1.se
DocumentRoot "C:/xampp/htdocs/website_1.se"
</VirtualHost>
<VirtualHost *:80>
ServerName website_2.se
ServerAlias www.website_2.se
DocumentRoot "C:/xampp/htdocs/website_2.se"
</VirtualHost>
So when enter www.site_1.se I get to localhost(htdocs)/site_1.se. And when I enter www.site_2.se I get to localhost(htdocs)/site_2.se and so on. Perfect, that's the point.
Now here is the problem. These folders (site_1.se & site_2.se) contains html-files, and in these files I have links with addresses that starts with '/', which refers to the root.
So for example if have: <img src="/images/file.png">
inside a html-file in site_1.se, Apache tries to locate the image in:
localhost/site_1.se/images/file.png (if entering www.site_1.se)
or
localhost/images/file.png (if entering localhost/site_1.se)
So this obviously becomes a problem when developing in localhost and using '/' at the beginning of paths. Because when you then visit the page from the domain name, the links are wrong.
So I'm wondering how can I set up apache, so I can specify paths starting with '/', and get the same root no matter how I visit the site?