-1

I'm working locally and I always specify files as /files.jpg or whatnot so the server will always know to look at the root level to find the files. That way if I'm on a subpage it won't choke. But locally the files do not show up. My file structure is apache2/htdocs/name_of_folder. name_of_folder is my "root". I then modify my virtualhost file so when I enter localhost/name_of_folder it will show my site. I specify the DocumentRoot so I thought when I say localhost/name_of_folder that is working at the document root?

In httpd-vhosts.conf I have it set to

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/opt/local/apache2/name_of_folder"
    ServerName localhost/name_of_folder
    ServerAlias www.localhost/name_of_folder
    ErrorLog "logs/name_of_folder_log"
    CustomLog "logs/name_of_folder_access_log" common
</VirtualHost>

What am I doing wrong?

4

3 回答 3

0

您正在滥用ServerNameServerAlias指令。它们与文件或路径无关。它们是标识网站的域名(如果不是 80,则与可选端口一起)。如果要移动文档根目录,则必须编辑DocumentRoot指令。

于 2011-07-23T13:51:37.910 回答
0

You may not do this in that way. The directive ServerName is not supposed to get an URL but a domain name. Set the root to the parent folder, deny all access to it using <Directory> and allow access to you subdirectory to get it work.

于 2011-07-23T13:54:48.123 回答
0

而不是这样做:

ServerName localhost/name_of_folder
ServerAlias www.localhost/name_of_folder

创建子域:

ServerName subdomain.localhost
于 2011-07-23T14:00:48.543 回答