473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I redirect requests based on host?

Hi,

I have two domains pointing to the same ISP hosted web site.
How can I redirect request for www.domain2.com to a sub-folder using header
field "host"?
Thanks a lot...

J-

Jul 17 '05 #1
5 9616
Carved in mystic runes upon the very living rock, the last words of Jay
Shen of comp.lang.php make plain:
I have two domains pointing to the same ISP hosted web site.
How can I redirect request for www.domain2.com to a sub-folder using
header field "host"?


In your index file:

if (ereg("domain2.com", $_SERVER['HTTP_HOST'])) {
header("Location: /subfolder/");
}

After that of course you'll have to make sure all your links include the
subfolder path.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #2
Alan Little wrote:

Carved in mystic runes upon the very living rock, the last words of Jay
Shen of comp.lang.php make plain:
I have two domains pointing to the same ISP hosted web site.
How can I redirect request for www.domain2.com to a sub-folder using
header field "host"?


In your index file:

if (ereg("domain2.com", $_SERVER['HTTP_HOST'])) {
header("Location: /subfolder/");
}

After that of course you'll have to make sure all your links include the
subfolder path.


I've heard that some browsers have trouble with the Location header if you don't
include the full url, but I'm not sure if which ones. You might want to try:

header("Location: http://www.domain2.com/subfolder/");

--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #3
In article <KO***************@newssvr14.news.prodigy.com>, Jay Shen's
output was...
Hi,

I have two domains pointing to the same ISP hosted web site.
How can I redirect request for www.domain2.com to a sub-folder using header
field "host"?


Surely your ISP can set up name-based virtual hosts under Apache?

http://httpd.apache.org/docs-2.0/vhosts/
Jul 17 '05 #4
Shawn Wilson wrote:
I've heard that some browsers have trouble with the Location header
if you don't include the full url,


The field value of the Location HTTP header must consist of an
absolute URL; a relative URL would contravene RFC2616, sec. 14.30.
Resultantly, relying on relative URLs working is unwise, despite
applications supporting them.

--
Jock
Jul 17 '05 #5
Similarly, if you're running Apache, you can do this without having to worry
about links by using mod_rewrite and checking what the hostname specified in
the URL was. Check out the documentation for mod_rewrite:

http://httpd.apache.org/docs/mod/mod_rewrite.html (Apache 1.3)
http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html (Apache 2.0)

Hope that helps.

EE

"Eto Demerzel" <et**********@fijivillage.com> wrote in message
news:MP************************@news-text.blueyonder.co.uk...
In article <KO***************@newssvr14.news.prodigy.com>, Jay Shen's
output was...
Hi,

I have two domains pointing to the same ISP hosted web site.
How can I redirect request for www.domain2.com to a sub-folder using header field "host"?


Surely your ISP can set up name-based virtual hosts under Apache?

http://httpd.apache.org/docs-2.0/vhosts/

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dan glenn | last post by:
Hi, I'm hoping someone out there has experienced this and can tell me right off what is going on. I'm getting a double slash in my URL when I do a redirect if my host is a 'web' host, but when...
2
by: D. Nii | last post by:
Hi there, I have a web application that recently got redesigned and now makes use of Response.Redirect . The "new" application is hosted on Win2000 and works for all kinds of clients using IE...
1
by: Brian Smith | last post by:
Good afternoon. How can I force all images and static html files within an ASP.NET Web Application to be redirected if the user has not logged in yet via Forms Authentication. For example, I...
2
by: Peter McEvoy | last post by:
Folks, I've been building a Webservice API for a contract that will be exposed to the internet at large. There are two endpoints, and each endpoint contains a number of webmethods. Every...
5
by: deko | last post by:
I'm trying to redirect requests for /index.php to /mydirectory/index.php If I use an index file in / with only this line: <?php header("Location:http://www.mysite.com/mydirectory/"); ?> that...
12
by: =?Utf-8?B?cGI=?= | last post by:
I am having trouble doing a redirect in an async asp.net implemention. Most of the time it works, but when it doesn't it just "hangs", the browser never gets any return page. If I run it under the...
7
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am trying to set this up using asp code and IIS configuration. But it seems not working. Here it is the way I am doing. In IIS I set up a virtual directory with secure communication, I...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
3
by: =?Utf-8?B?UGF0UA==?= | last post by:
We have a site that gets many requests for nonexistent pages, files and folders. We want those requests redirected to the index page. However, for static files (i.e. images and some other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.