gpt4 book ai didi

.htaccess - 使用 htaccess 将所有域别名重定向到一个

转载 作者:行者123 更新时间:2023-12-03 20:48:30 24 4
gpt4 key购买 nike

我有几个域别名,而我只想实际使用其中一个。
目前,我安装了两个域,

要重定向,我想使用 htaccess。

我的域目前是这样工作的:

www.domain.com/index.html - 主域的主页

www.secondDomain.com/index.html - 显示与主域完全相同的主页,但我希望它在使用时自动将 url 重命名为 www.domain.com/index.html。

谢谢!

最佳答案

匹配很简单的事情%{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]

关于.htaccess - 使用 htaccess 将所有域别名重定向到一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12248788/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com