How To Access a Html file: /var/www/html/file? Simple question

November 23, 2015 1k views

Hi everyone.

I have uploaded my landing page files. the index.html + graphics to /var/www/html/landingpage/

the problem is when I try to access the files via my domain,

It does not work.

But this link works:

So I have to add a / on the end of my url to access my site.

Is is possible to make this automatic somehow?

1 comment
4 Answers

Hello @barrorod this is caused because you probably need to add the / inside the VHOST.
Please post your VHOST of apache here or add the / at the end of your root.
Or add this to your VHOST with modification to your environment, this will try to run the proper directory:

location / {
    try_files $uri $uri/ $uri.html;

You shall use the DirectoryIndex directive in your httpd.conf or htaccess. Example:

DirectoryIndex index.html index.htm

@CrypticDesigns - The location directive is for NGINX :-). He's using a LAMP Stack, thus, Apache is the web server he's currently using. What you've provided would work if he was looking to compare the request to an existing HTML file though (i.e. would attempt to serve about.html).

An issue arises, however, when a file does not exist. If that block is to be used, then error pages need to be defined as well, otherwise you'll be looking at a black & white error if the file cannot be found (this applies to HTML files -- if PHP was being used, this would be a non-issue as the request would still route to index.php).

@barrorod - @Halonen is correct. You'll need to define your DirectoryIndex directive and list indexes in the order that you'd like Apache to attempt.

For example, if we used the example provided by @Halonen , Apache will first attempt to find index.html followed by index.htm. If neither of these files exist, you'll either see an error page or you'll be able to view the contents of the directory.


If defining the DirectoryIndex directive does not work, please post your VirtualHost configuration.

  • @jtittle Yes indeed I am sorry, I was working on alot of things at one moment. I use NGINX all the time on all my systems so it confused me a bit I guess.
    Atleast we got some other active people willing to support and give proper answers haha

Thank you for Your answers guys. I am still very New to this so the easiest way for me was to Access my landing page was to point my browser to this url:

@CrypticDesigns I am not sure how to post .VirtualHost configuration, But I will Google around and find out :)

Have another answer? Share your knowledge.