English 中文(简体)
我如何根据《家庭福利法》改用不同的网页。
原标题:How do I redirect to different page depending on the HOSTNAME .htacces with a Rewrite Condition/Rule

我有一个网站:www.asdf.com和www.fdsa.com。

我怎么能检查一下“红外线”的去向,并将其转往不同的网页?

我知道这一点:

RewriteRule (%{HTTP_HOST})^(.*)$ http://www.gunslot.com/$2 [L,R=301]

基本上,我如何在加入(假冒代码)时这样做。

if(hostname == "asdf") redirect to asdf.com/hello.html
if(hostname == "fdsa") redirect to asdf.com/goodbye.html
问题回答

你们试图取得什么成就并不明确,但答案是你们要求的。

.htaccess

RewriteCond %{HTTP_HOST} ^asdf.com
RewriteRule ^(.*)$ http://asdf.com/hello.html [NC,L]

RewriteCond %{HTTP_HOST} ^fdsa.com
RewriteRule ^(.*)$ http://asdf.com/goodbye.htm [NC,L]

如果您想将任何请求转至<><>sdf area to hello.html on asdf, 以及任何要求fdsa goodbye.html>>>>>>>/em>在贵方域内添加以下内容。

RewriteEngine On
RewriteBase /
#Redirect any asdf domain or subdomain
RewriteCond %{HTTP_HOST} ^(.+.)?asdf.com$ [NC]
RewriteCond %{REQUEST_URI} !^/(hello|goodbye).html$ [NC]
RewriteRule . http://asdf.com/hello.html [L,R]

#Redirect any fdsa domain or subdomain
RewriteCond %{HTTP_HOST} ^(.+.)?fdsa.com$ [NC]
RewriteRule . http://asdf.com/goodbye.htm [L,R]




相关问题
URL rewrite in IIS6 - Third party tools

I have collected the following api/sdk/whatever which provide modules for doing url rewriting in IIS 5/6/7. Some are free-open source and some require $. I haven t tried any of them. I would like to ...

Rewrite spring-security redirect URLs

I m trying to get Tuckey UrlRewriteFilter to tidy up URLs for my webapp. One problem I ve got is that when spring-security notices that an anonymous user is trying to access a protected resource it ...

ASP.NET Friendly URLs

In my research, I found 2 ways to do them. Both required modifications to the Application_BeginRequest procedure in the Global.Asax, where you would run your code to do the actual URL mapping (mine ...

Could I get by HttpModule the URL that contains * before?

My web-site is working under ASP.NET 3.5, IIS7, Integrated pipiline mode. My HttpModule is getting request to all resources, including URLs like this: http://my-site.com/address And I would support *...

Domains & Foreward Slash

This is rather difficult to explain so please bear with me. We will be hosting 4 websites on our server and the plan is to have each site sit under its own domain: site-a.com site-b.com sub1.site-b....

URL Mod-Rewrite

I currently have a working URL: http://example.com/security-services.php?service=fixed-camera-surveillance and then I have PHP say, $_REQUEST[ service ] to do some stuff... But I d like to ...