By Kfir Ben-Ami
Hello!
Since I might host several static websites on the same droplet I’ve used apache’s virtual host. As a result, in my /var/www I have folders that correspond the domain name. For example: /var/www/example.com/public and /var/www/another.com/public.
in my sites-available (/etc/apache2/sites-available) I have:
• 000-default.conf
• default-ssl.conf
• example.com.conf
• another.com.conf
example.com.conf and another.com.conf are configured just fine. They redirect to the desired folder in /var/www and everything works perfectly fine. However, when I try to access my IP address directly, it points me to /var/www/html because that’s how it’s set in 000-default.conf.
I’ve edited 000-default.conf and changed its DocumentRoot to be /var/www/example.com/public as I wish this website to be the “main” website when requesting the domain.
As expected, it works just fine. However, I’ve noticed that it keeps the IP address in the URL. I tried several things to make it change the URL to example.com just as if I was accessing example.com from the URL directly and not the IP address.
Unfortunately, I couldn’t get it work. Any idea how I can implement it without using some “hacks” such as directing the IP address to /var/www/html and store in there a .htaccess that will redirect me to example.com. I would like to store that logic in the 000-default.conf file.
Thanks in advance!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Dear all After I try at apache 2.2 in centos 6.6, I got the error code as shown as the link of https://drive.google.com/open?id=1ECqgv2OMOasblGl66ZZTBWQ_7mvUCbK-
My code is as listed as the link https://drive.google.com/file/d/1VCj8xO8HUr7b98ys0KCSCLz2u3MOEr4w/view?usp=sharing
Is there suggestion for the problem? Thanks for your kindly assistance.
This comment has been deleted
Kwaifeh,
I cannot remember for certain what I did (I did resolve it), but make sure you have mod_rewrite enabled for apache.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.