Relative and absolute path on Apache localhost

I installed Apache on my local computer (Windows 7 using AppServ). I opened a library called "MySite" in the AppServ directory, so I use the following URL to access it:

http://127.0.0.1/MySite 

The problem is that when I use

 <link type='text/css' href='/stylesheets/main.css' rel='stylesheet' media='all' /> 

The file is not loaded because it is trying to find it in http://127.0.0.1/ instead of http://127.0.0.1/MySite .

How can i change this?

Thanksm

Joel

+4
source share
3 answers

Modify apache.conf file and set DocumentRoot to MySite

+1
source

Actually, your question shows a flaw in your setup :

You want http://127.0.0.1/MySite point to a specific directory, for example /var/www/MySite .

It follows that

  • http://127.0.0.1/ points to /var/www/ and that
  • http://127.0.0.1/stylesheets points to /var/www/stylesheets .

But you want http://127.0.0.1/stylesheets point to a subdirectory, say /var/www/MySite/stylesheets.

It is possible, but probably not very wise.

Workarounds:

  • Add an alias for / stylesheets to /var/www/MySite/stylesheets
  • Install DocumentRoot on /var/www/MySite and go to the site using http://127.0.0.1
  • virtual domains
  • Rewrite rules
+1
source

All Articles