Saturday, 19 December 2015

How to redirect domain in apache server


Add following code to your .htaccess or httpd.conf (directory directive) file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
If you added directives to httpd.conf, restart Apache:

# service httpd restart
#chkconfig httpd on

1 comment: