<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>seigafuse.com &#187; PHP</title>
	<atom:link href="http://seigafuse.com/category/technology/opensource/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://seigafuse.com</link>
	<description>Mike Seigafuse&#039;s Technology and IT Security Blog</description>
	<lastBuildDate>Fri, 20 Aug 2010 16:23:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Redirecting based on the URL passed</title>
		<link>http://seigafuse.com/2007/01/25/redirecting-based-on-the-url-passed/</link>
		<comments>http://seigafuse.com/2007/01/25/redirecting-based-on-the-url-passed/#comments</comments>
		<pubDate>Fri, 26 Jan 2007 03:19:24 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://seigafuse.com/?p=23</guid>
		<description><![CDATA[I needed to consolidate a couple of servers down to a single machine, but the system&#8217;s users were used to entering a certain URL. DNS was the easy part, just create a CNAME record to point to the host. But how to direct users who enter the CNAME (call it cname.domain.com for example) to one [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to consolidate a couple of servers down to a single machine, but the system&#8217;s users were used to entering a certain URL.  DNS was the easy part, just create a CNAME record to point to the host.  But how to direct users who enter the CNAME (call it cname.domain.com for example) to one directory while still directing the users from the original host (using hostname.domain.com) to the content they are used to seeing?  There are probably more elegant ways to do this, but I simply created an index.php file to look at the URL passed and redirect them to the proper content.  See the file below:</p>
<p><a href="javascript:showme('8318_1');"> <b>> index.php</b></a>
<div style="display: none; background:white;" id=8318_1>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #0000ff;">$host_passed</span> = <span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'HTTP_HOST'</span><span style="color: #66cc66;">&#93;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/strtolower"><span style="color: #000066;">strtolower</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$host_passed</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">"cname.domain.com"</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Location: /cnameweb/index.html"</span><span style="color: #66cc66;">&#41;</span>;
	<a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
	<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Location: /index.html"</span><span style="color: #66cc66;">&#41;</span>;
	<a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://seigafuse.com/2007/01/25/redirecting-based-on-the-url-passed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
