开发者

Files not showing up because looking at root but I think I specify the root!

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/apac开发者_如何学运维he2/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?


You are misusing the ServerName and ServerAlias directives. They have nothing to do with files or paths. They are the domain name that identifies the web site (together with an optional port if not 80). If you want to move your document root, you have to edit the DocumentRoot directive.


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.


In stead of doing:

ServerName localhost/name_of_folder
ServerAlias www.localhost/name_of_folder

Create a subdomain:

ServerName subdomain.localhost
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜