通配符子域模重写 [英] Wildcard subdomain mod-rewrite

查看:196
本文介绍了通配符子域模重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通配符子域名 *。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]

这篇关于通配符子域模重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆