<?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>Pixil.info &#187; redirectrs</title>
	<atom:link href="http://pixil.info/tag/redirectrs/feed/" rel="self" type="application/rss+xml" />
	<link>http://pixil.info</link>
	<description>We make video tuts on design and development.</description>
	<lastBuildDate>Tue, 10 Aug 2010 23:06:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Redirects using htaccess</title>
		<link>http://pixil.info/tutorials/programming/redirects-using-htaccess/</link>
		<comments>http://pixil.info/tutorials/programming/redirects-using-htaccess/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 17:09:30 +0000</pubDate>
		<dc:creator>Jeremy Simkins</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[redirectrs]]></category>
		<category><![CDATA[redirects]]></category>
		<category><![CDATA[RewriteEngine]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://pixil.info/?p=340</guid>
		<description><![CDATA[A quick look at redirects using htaccess. Today I’m going to show you how to force a www and a...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpixil.info%2Ftutorials%2Fprogramming%2Fredirects-using-htaccess%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpixil.info%2Ftutorials%2Fprogramming%2Fredirects-using-htaccess%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>A quick look at redirects using htaccess.</strong></p>
<p>Today I’m going to show you how to force a www and a non www domain using htaccess.
<p>
<span id="more-340"></span></p>
<p>It’s common knowledge that you can access your site with or without the www. By not forcing one or the other this will penalize your SEO, due to duplicate content.  The most common method of doing this is via .htaccess using mod_rewrite.</p>
<p>When I was first learning how to use .htaccess this was one of the simpler methods to find examples of with any search engine. Now, if you are only needing to edit your. htaccess for one domain, the majority of these found examples will suffice; If you have multiple domains that tend to go to one directory this example will be much more beneficial. Also, if you put this example into your httpd.conf file, this can take effect on all domains on the server; so you won’t need to worry about adding each domains redirect.</p>
<p>I have provided the below examples as a method I use to manage redirects. I have provided an example for each method, www and non-www.</p>
<p>In order for mod_rewrite to work you must first enable it. This is easily done by adding this to the .htaccess.</p>
<blockquote><p>RewriteEngine On<br />
Force www:<br />
# Do a www redirect on the domain<br />
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]<br />
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC]<br />
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]</p>
<p>Force non-www<br />
# Do a non-www redirect on the domain<br />
RewriteCond %{HTTP_HOST} ^www\.[a-z-]+\.[a-z]{2,6} [NC]<br />
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC]<br />
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]</p></blockquote>
<p><strong>How this works:</strong></p>
<p>When the URL is being received we check it to ensure it is valid to our method of choice. Regardless of our method, it checks the URL to see if it matches, checks if the URL contains the www or not. Next it will set the conditional variable to be used in the actual redirect.</p>
]]></content:encoded>
			<wfw:commentRss>http://pixil.info/tutorials/programming/redirects-using-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
