答案 0 :(得分:1)
要重写此域名:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.co\.in$ [NC]
RewriteRule ^(.*)$ http://www.domain.co.in$1 [L,R,QSA]
在一个规则中重写多个域:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [L,R,QSA]
答案 1 :(得分:1)
在网络根目录中创建.htaccess,
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.co.in [nc]
RewriteRule ^(.*)$ http://www.domain.co.in/$1 [R=301,L]
答案 2 :(得分:1)
这样做不需要mod-rewrite复杂性,最基本的配置可以更好地完成工作(更简单=更好)。
创建一个虚拟主机,其中包含要重定向的所有域(ServerName
中的一个ServerAlias
中的其他域。在其中使用Redirect
到右边的那个,你只使用一个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>