4

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

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 since it tries to look it in http://127.0.0.1/ instead of http://127.0.0.1/MySite .

How can I change this?

Thanksm

Joel

Joel
  • 5,949
  • 12
  • 42
  • 58

3 Answers3

1

Edit your apache.conf File and set your DocumentRoot to MySite

MnomrAKostelAni
  • 458
  • 1
  • 4
  • 13
  • Thanks, but is there any way to change the apache settings so it will act as required? – Joel Nov 09 '10 at 10:03
1

Actually, your question shows a flaw in your setup:

You want http://127.0.0.1/MySite to point to a certain directory, say /var/www/MySite.

This implies 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 to point to a subdirectory, say /var/www/MySite/stylesheets.

It's possible, but probably not very wise.

Workarounds:

  • Add an Alias for /stylesheets to /var/www/MySite/stylesheets
  • Set the DocumentRoot to /var/www/MySite and access the site with http://127.0.0.1
  • vhosts
  • Rewrite rules
Konerak
  • 39,272
  • 12
  • 98
  • 118
0

You could change documentRoot:

http://httpd.apache.org/docs/2.0/mod/core.html#documentroot