I installed Apache2 on Ubuntu and put everything in /var/www/html for my linked domain name. Is this where its supposed to be on Apache 2? Its the only place that its been working for me…
But how do I stop my domain (typing in domain.tld) from automatically going to domain.tld/html/? The website displays ok but can’t I just get it to show the contents of the html file (and their subdirectories) and show domain.tld?
I have tried some .htaccess fixes but to no avail. I also have some code in my .htaccess which redirects http:// to https:// and that is at least working now.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Maybe if I put my ServerName as the IP address it would help?
Here’s my 000-default.conf file, (domain.tld.conf is the same because I’m not sure which one the browser is reading)
It only seems to be an issue when www. is in front of the address; otherwise it doesn’t redirect. Maybe its because of the ServerName, ServerAlias combo I used?
While for the question “Is this where it’s supposed to be on Apache 2?”: as you might evince from kamaln7 answer, you can place your files in the directory you prefer (don’t forget to give it the proper owner and permissions) and then change your VirtualHost’s configuration accordingly.
If your VirtualHost’s DocumentRoot is set to
/var/www
, you will need to set it to/var/www/html
so thathttp://yourdomain.tld/
maps to/var/www/html
instead of/var/www
.Open your VirtualHost file in
nano
:and set DocumentRoot to
/var/www/html
.Then restart Apache: