Redirecting all domain aliases to one with htaccess

前端 未结 1 1544
庸人自扰
庸人自扰 2021-02-06 03:45

I have a few domain aliases, while I only want one of them to be actually used. At the moment, I have two domains installed,

To redirect I\'d like to use htaccess.

1条回答
  •  粉色の甜心
    2021-02-06 04:47

    It is a simple matter of matching %{HTTP_HOST} not equal to www.domain.com and redirecting that to the canonical domain.

    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]
    

    0 讨论(0)
提交回复
热议问题