子域通配符htaccess的重定向到新的域名通配符、到新、重定向、域名

2023-09-02 09:51:58 作者:橘子果酱o

我的一个网站,我想重定向Ø另一个域。

One of my websites I want to redirect o another domain.

情况:

[老] * .example.com的 [新] * .example.net

[old] *.example.com [new] *.example.net

现在我有这个在我的htaccess

for now I have this in my htaccess

#RewriteCond %{HTTP_HOST} ^(.*).allwebsitestats.com [NC]
#RewriteRule ^(.*)$ http://$1.allwebsitestats.nl [R=301,L]

该操作的结果;

The result of this;

请求[老] * .example.com的在[新] .example.net,问题是结果 它不会通配符子域吧。

Request [old] *.example.com results in [new] .example.net, the problem is it doesn't get the wildcard subdomain with it.

谢谢你!

问候, 尼克

推荐答案

的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT 目录下:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(.+?).allwebsitestats.com$ [NC]
RewriteRule ^ http://%1.allwebsitestats.nl%{REQUEST_URI} [R=301,L]