Sometimes we host website or application on Apache on Linux. After hosting, we hit URL: www.mydomain.com so it's working fine. But when I hit server IP that time also it's working. But not redirect to www.mydomain.com
So today We set IP to Domain Redirection in Apache. Using RewriteEngine rule.
IP to Domain Name Redirect
Insert following code into your <VirtualHost *:80> file. and replace highlighted text with your IP and domain name.
Enable RewriteEngine
So today We set IP to Domain Redirection in Apache. Using RewriteEngine rule.
IP to Domain Name Redirect
Insert following code into your <VirtualHost *:80> file. and replace highlighted text with your IP and domain name.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^34\.239\.44\.197$
RewriteRule ^(.*)$ http://www.serverkaka.com/$1 [L,R=301]
|
Enable RewriteEngine
# sudo a2enmod rewrite
|
Restart Apache
# sudo service apache2 restart
|