Anyone please help me to redirect in apache webserver
My domains which have .co.in extensions
http://domain.co.in should be redirected to http://www.domain.co.in
Anyone please help me to redirect in apache webserver
My domains which have .co.in extensions
http://domain.co.in should be redirected to http://www.domain.co.in
To rewrite just this domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.co\.in$ [NC]
RewriteRule ^(.*)$ http://www.domain.co.in$1 [L,R,QSA]
To rewrite for multiple domains in one rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [L,R,QSA]
create a .htaccess in the web root,
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.co.in [nc]
RewriteRule ^(.*)$ http://www.domain.co.in/$1 [R=301,L]
You do not need mod-rewrite complexity to do that, the most basic configuration will do the job better (simplier=better).
Make one Virtualhost, containing all domains to be redirected (one in ServerName
the others in ServerAlias
). Inside it use Redirect
to the right one, where you use only one ServerName.
<VirtualHost *:80 />
# catch all DNS to be redirected here
ServerName redirect.domain.co.in
ServerAlias domain.co.in
ServerAlias domain.org
ServerAlias domain_co_in.com
Redirect permanent / http://www.domain.co.in/
</VirtualHost>
<VirtualHost *:80 />
# The real VH with only one name
ServerName www.domain.co.in
(...)
</VirtualHost>