<?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>Stijn D&#039;haese &#187; Apache</title>
	<atom:link href="http://blog.stijn-dhaese.be/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stijn-dhaese.be</link>
	<description>stijn-dhaese.be is the weblog and portfolio of Stijn D&#039;haese. A little freedom on the net by an analyst, designer and developer from Belgium.</description>
	<lastBuildDate>Wed, 28 Oct 2009 12:25:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to invisible redirect websites in Apache. [updated]</title>
		<link>http://blog.stijn-dhaese.be/2007/10/how-to-invisible-redirect-websites-in-apache-updated/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-invisible-redirect-websites-in-apache-updated</link>
		<comments>http://blog.stijn-dhaese.be/2007/10/how-to-invisible-redirect-websites-in-apache-updated/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 14:24:54 +0000</pubDate>
		<dc:creator>Stijn</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.stijn-dhaese.be/blog/?p=3</guid>
		<description><![CDATA[
Problem: You have 1 hosting package but 2 websites. How do you make a nice looking redirect, so that they run nicely side by side, with .htaccess?

There are 2 common hosting situations that I will explain, the first is VirtualDocumentroot what gives you access to sub domains (example: http://image.domain.com). The other one is Documentroot what [...]]]></description>
			<content:encoded><![CDATA[<p><center><a href="http://www.pcextreme.nl/?tt=1652_44885_27592_" target="_blank"><img src="http://ti.tradetracker.net/?c=1652&amp;m=44885&amp;a=27592&amp;t=html" border="0" alt="" width="468" height="60" /></a></center></p>
<p class="intro"><strong>Problem</strong>: <em>You have 1 hosting package but 2 websites. How do you make a nice looking redirect, so that they run nicely side by side, with .htaccess?</em></p>
<p><span id="more-3"></span></p>
<p>There are 2 common hosting situations that I will explain, the first is VirtualDocumentroot what gives you access to sub domains (example: http://image.domain.com). The other one is Documentroot what will lead all the traffic to the www folder (http://www.domain.com is the same as http://domain.com).</p>
<p>Here you can see a <a href="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/virtualdocumentroot.jpg">demo</a> of virtual root (sort of).</p>
<h3>VIRTUALDOCUMENTROOT.</h3>
<p><a href="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/simple_example.jpg"><img src="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/simple_example.jpg" alt="" title="VirtualDocumentRoot" width="106" height="87" class="alignright size-full wp-image-5" /></a>When you use VirtualDocumentroot, you have a root folder where you can place sub folders who represent sub domains. In the figure &#8220;VirtualDocumentroot&#8221; you can see an example of a basic hosting package using VirtualDocumentroot. There is an www-folder who represents http://www.domain.com and you have an image folder who represents http://image.domain.com.</p>
<p>The first thing we are going to do, is to create a .htaccess file that will move all the traffic without a sub domain to the www-folder (http://domain.com becomes http://www.domain.com). Copy and modify the following code in a standard text-editor like notepad or gedit:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="" style="font-family:monospace;">RewriteEngine On
&nbsp;
RewriteCond %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> ^WebsiteNameA.com$ <span class="br0">&#91;</span>NC<span class="br0">&#93;</span>
RewriteRule ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ http://www.WebsiteNameA.com/ <span class="br0">&#91;</span>R=<span style="">301</span>,L<span class="br0">&#93;</span>
&nbsp;
RewriteCond %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> ^WebsiteNameB.com$ <span class="br0">&#91;</span>NC<span class="br0">&#93;</span>
RewriteRule ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ http://www.WebsiteNameB.com/ <span class="br0">&#91;</span>R=<span style="">301</span>,L<span class="br0">&#93;</span></pre></td></tr></table></div>

<p>Save as .htaccess (be careful when using windows <a href="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/windowssave.jpg">not to add an extension</a>) and upload it to your root folder (/) This .htaccess-file still makes it possible to use sub domains like http://image.domain.com, keep in mind that in this example it doesn&#8217;t mather witch domain name you use. Both image.WebsiteNameA.com and image.WebsiteNameB.com will work for this example.</p>
<p>The next thing we will do is separate both domains. For this example I made 2 folders called websitea and websiteb in the www-folder. The names you use aren&#8217;t important, you could easily use &#8216;cake&#8217; and &#8216;beer&#8217; as long you change the names in your second .htaccess file. What brings us to .htaccess file number 2. Again, copy and modify the following code in a standard text-editor like notepad or gedit, the /websitea is the folder name of the corresponding domain:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="" style="font-family:monospace;">RewriteCond %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> ^www.WebsiteNameA.com$
RewriteCond %<span class="br0">&#123;</span>REQUEST_URI<span class="br0">&#125;</span> !/websitea
RewriteRule ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ /websitea/$<span style="">1</span>
&nbsp;
RewriteCond %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> ^www.WebsiteNameB.com$
RewriteCond %<span class="br0">&#123;</span>REQUEST_URI<span class="br0">&#125;</span> !/websiteb
RewriteRule ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ /websiteb/$<span style="">1</span></pre></td></tr></table></div>

<p><a href="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/endvirtual.jpg"><img src="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/endvirtual.jpg" alt="" title="End result VirtualDocumentroot" width="134" height="135" class="alignleft size-full wp-image-12" /></a>And again you need to save the file as .htaccess but this time you upload the file in the www-folder! See the figure &#8220;End result VirtualDocumentroot&#8221; to get a clue.</p>
<p>Let me explain what this file does, whenever people visit website A or B, the server will get the files out the corresponding folder. In this case the server will get all the files for http://www.WebsiteNameA.com out folder /www/websitea and for http://www.WebsiteNameB.com out folder /www/websiteb. The cool thing about this is that the user won&#8217;t see it happen, unlike the redirect of http://WebsiteNameA.com to http://www.WebsiteNameA.com, you also don&#8217;t need to worry about complex url&#8217;s like http://www.WebsiteNameA.com/index.php?id=12&#038;other=test or http://www.WebsiteNameA.com/image/file.jpeg. If all the corresponding files are in the right folder, it will work.</p>
<p>One thing though, when you use full paths in your website&#8217;s you need to keep in mind that it&#8217;s now /www/websitea (or /www/websiteb), but normally this won&#8217;t be a problem in modern cms or blog engines like wordpress.</p>
<h3>DOCUMENTROOT.</h3>
<p>DocumentRoot is almost the same like VirtualDocumentroot, with the exception that your root folder is your www-folder and you don&#8217;t have sub domains. The good news is that there is less work to invisible redirect website.</p>
<p><a href="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/enddocum.jpg"><img src="http://www.stijn-dhaese.be/blog/wp-content/uploads/2008/11/enddocum.jpg" alt="" title="DocumentRoot" width="114" height="74" class="alignright size-full wp-image-13" /></a>Lets get started, the first thing we need to do is to split or 2 website into 2 folder. All files from website A will go in folder websitea and all files of website B will go in folder websiteb (see image &#8216;DocumentRoot&#8217; for an example). The names of the folders aren&#8217;t important as long you change them in the .htacces file, what brings us to the next part: the .htaccess file. Copy and modify the following code in a standard text-editor like notepad or gedit:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="" style="font-family:monospace;">RewriteCond %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> ^www.WebsiteNameA.com$
RewriteCond %<span class="br0">&#123;</span>REQUEST_URI<span class="br0">&#125;</span> !/websitea
RewriteRule ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ /websitea/$<span style="">1</span>
&nbsp;
RewriteCond %<span class="br0">&#123;</span>HTTP_HOST<span class="br0">&#125;</span> ^www.WebsiteNameB.com$
RewriteCond %<span class="br0">&#123;</span>REQUEST_URI<span class="br0">&#125;</span> !/websiteb
RewriteRule ^<span class="br0">&#40;</span>.*<span class="br0">&#41;</span>$ /websiteb/$<span style="">1</span></pre></td></tr></table></div>

<p>After you modified the file, save as .htacces and upload it into your root folder.</p>
<p>Let me explain what this file does, whenever people visit website A or B, the server will get the files out the corresponding folder. In this case the server will get all the files for http://www.WebsiteNameA.com out folder /websitea and for http://www.WebsiteNameB.com out folder /websiteb. The cool thing about this is that the user won&#8217;t see it happen, you also don&#8217;t need to worry about complex url&#8217;s like http://www.WebsiteNameA.com/index.php?id=12&#038;other=test or http://www.WebsiteNameA.com/image/file.jpeg. If all the corresponding files are in the right folder, it will work.</p>
<p>Good luck and if you have any questions, feel free to ask them.</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D&amp;bodytext=%0D%0AProblem%3A%20You%20have%201%20hosting%20package%20but%202%20websites.%20How%20do%20you%20make%20a%20nice%20looking%20redirect%2C%20so%20that%20they%20run%20nicely%20side%20by%20side%2C%20with%20.htaccess%3F%0D%0A%0D%0A%0D%0AThere%20are%202%20common%20hosting%20situations%20that%20I%20will%20explain%2C%20the%20first%20is%20VirtualDocumentroot%20what" title="Digg"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F" title="Sphinn"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D&amp;notes=%0D%0AProblem%3A%20You%20have%201%20hosting%20package%20but%202%20websites.%20How%20do%20you%20make%20a%20nice%20looking%20redirect%2C%20so%20that%20they%20run%20nicely%20side%20by%20side%2C%20with%20.htaccess%3F%0D%0A%0D%0A%0D%0AThere%20are%202%20common%20hosting%20situations%20that%20I%20will%20explain%2C%20the%20first%20is%20VirtualDocumentroot%20what" title="del.icio.us"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;t=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D" title="Facebook"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D" title="Mixx"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D&amp;annotation=%0D%0AProblem%3A%20You%20have%201%20hosting%20package%20but%202%20websites.%20How%20do%20you%20make%20a%20nice%20looking%20redirect%2C%20so%20that%20they%20run%20nicely%20side%20by%20side%2C%20with%20.htaccess%3F%0D%0A%0D%0A%0D%0AThere%20are%202%20common%20hosting%20situations%20that%20I%20will%20explain%2C%20the%20first%20is%20VirtualDocumentroot%20what" title="Google Bookmarks"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D" title="Live"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;t=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D" title="MySpace"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D" title="Reddit"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D&amp;url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F" title="Slashdot"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.stijn-dhaese.be%2F2007%2F10%2Fhow-to-invisible-redirect-websites-in-apache-updated%2F&amp;title=How%20to%20invisible%20redirect%20websites%20in%20Apache.%20%5Bupdated%5D" title="StumbleUpon"><img src="http://blog.stijn-dhaese.be/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://blog.stijn-dhaese.be/2007/10/how-to-invisible-redirect-websites-in-apache-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
