首页 > 解决方案 > How can I solve the problem with fake/unwanted domain redirection?

问题描述

The problem is for some reason the website is accessible via fake/unwanted subdomains like:

whatever.example.com,
http://www.www.example.com,
ww2.example.com
blablala.example.com

The goal is to redirect from fake/unwanted subdomains to http://www.example.com using .htaccess Every contribution would be fully appreciated.

标签: regexapache.htaccessredirectmod-rewrite

解决方案


把它放在 .htaccess 文件中:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [L,R=301,QSA]

推荐阅读