通配符子域模重写通配符、重写、子域模

2023-09-02 01:14:23 作者:兜兜里有颗糖

我有一个通配符子域名 *。domain.com 分配到的public_html /。

I have a wildcard subdomain *.domain.com assigned to public_html/.

我想使目录 www.domain.com/folder1/index.php?name=rock rock.domain.com

至于另外一个,我要让 www.domain.com/folder1/folder2/index.php?id=5 5 .domain.com

As for another one, I want to make www.domain.com/folder1/folder2/index.php?id=5 to 5.domain.com

有没有办法做到这一点?我在mod-rewrite一个初学者。真的AP preciate你的帮助。谢谢

Are there any way to do this? I'm a beginner in mod-rewrite. Really appreciate your help. Thanks

其他信息

我需要他们两个。它们将具有不同的变量。

I need both of them. They will have different variables.

例如,/folder1/index.php是基于状态的名字(?状态= Statename的)。

For example, /folder1/index.php is based on state name(?state=statename).

有关的/folder1/folder2/index.php,它会根据唯一的名称(?名= uniquename)。

For the /folder1/folder2/index.php, it will be based on unique name(?name=uniquename).

所以,www.domain.com/folder1/index.php?state=statename将statename.domain.com

So, www.domain.com/folder1/index.php?state=statename will be statename.domain.com

和www.domain.com/folder1/folder2/index.php?name=uniquename将uniquename.domain.com

and www.domain.com/folder1/folder2/index.php?name=uniquename will be uniquename.domain.com

感谢您

推荐答案

以下通用规则,应该为你工作:

Following generic rule should work for you:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+folder1/index.php?state=([^s&]+) [NC]
RewriteRule ^ http://%1.domain.com/? [R=301,L]

RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+folder1/folder2/index.php?name=([^s&]+) [NC]
RewriteRule ^ http://%1.domain.com/? [R=301,L]