I have installed LAMP server and set up website to get resolve the appropriate IP address so when I connect to a server with it’s domain name with an IP address in address bar. It looks like this; /etc/apache2/sites-available/default
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin ...
ServerName mydomainname.irrelevant.to.the.question
DocumentRoot /var/www
...
I think that was invented fix that behavior because I also recheck the 3xx redirect path. Path Redirect/RedirectMatch/RewriteRule directives . But in the php application apache won’t misbehave this kind of redirection with their tag Redirect or RewriteRule as I mentioned in the configure file. What else is required?
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!
Hi @jacobmillia,
It seems you are using the default Vhost, you need to create a new one for your domain name.
Here is how you can do it
Create a sites-enabled directory
You need to create a sites-enabled directory in your apache’s folder. Depending on the OS it can be either /etc/httpd or /etc/apache2
If you are on CentOS 7 you need to do the following
sudo mkdir /etc/httpd/sites-enabled
If you are on an Ubuntu, you need to
sudo mkdir /etc/apache2/sites-enabled
As soon as you have the folder created open your apache configuration file and add the following to the end of the file :
IncludeOptional sites-enabled/*.conf
Creating your Domain’s Vhost file
Start by opening the new file in your editor with root privileges:
For CentOS
sudo nano /etc/httpd/sites-available/example.com.conf
For Ubuntu
sudo nano /etc/httpd/sites-available/example.com.conf
The file itself should look something like this
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log combined
</VirtualHost>
Enable the New Vhost
Now that we have created our virtual host file, we need to enable it so that Apache knows to serve them to visitors.
If you are on CentOS, you need to do
sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf
If you are on Ubuntu, you need to
sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/example.com.conf
As soon as you are done, restart Apache and you should be good to go
Regards, KDSys
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.