Rad*_*ate 7 .htaccess redirect
我有一些域别名,而我只想要其中一个实际使用.目前,我安装了两个域,
重定向我想使用htaccess.
我的域名目前的工作原理如下:
www.domain.com/index.html - 主域名的主页
www.secondDomain.com/index.html - 显示与主域完全相同的主页,但我希望它在使用时自动将网址重命名为www.domain.com/index.html.
谢谢!
Mic*_*ski 21
这是一个简单的匹配问题,%{HTTP_HOST}不等于www.domain.com并将其重定向到规范域.
RewriteEngine On
# If the hostname is NOT www.domain.com
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
# 301 redirect to the same resource on www.domain.com
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
Run Code Online (Sandbox Code Playgroud)