<?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>CaptainCodeMonkey.com - All Your Booty Are Belong To Us! &#187; mod_rewrite</title>
	<atom:link href="http://www.captaincodemonkey.com/blog/tag/mod_rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.captaincodemonkey.com/blog</link>
	<description></description>
	<lastBuildDate>Sat, 01 May 2010 22:43:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>mod_rewrite to force www redirect index.php to domain</title>
		<link>http://www.captaincodemonkey.com/blog/2010/02/28/mod_rewrite-to-force-www-redirect-index-php-to-domain/</link>
		<comments>http://www.captaincodemonkey.com/blog/2010/02/28/mod_rewrite-to-force-www-redirect-index-php-to-domain/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 04:18:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming - General]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://www.captaincodemonkey.com/blog/?p=436</guid>
		<description><![CDATA[Here is a quick mod_rewrite example that forces www and redirects index.php to / (this fixes two canonicalization issues at one time). ?View Code PHPRewriteEngine on RewriteCond %&#123;HTTP_HOST&#125; !^www.site.com$ RewriteRule ^/&#40;.*&#41;$ http://www.site.com/$1 [R=301] RewriteRule ^/index\.php$ http://www.site.com/ [R=301,L]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick mod_rewrite example that forces www and redirects index.php to / (this fixes two canonicalization issues at one time).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p436code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4362"><td class="code" id="p436code2"><pre class="php" style="font-family:monospace;">RewriteEngine on
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>HTTP_HOST<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!</span>^www<span style="color: #339933;">.</span>site<span style="color: #339933;">.</span>com$
RewriteRule ^<span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.site.com/$1 [R=301]</span>
RewriteRule ^<span style="color: #339933;">/</span>index\<span style="color: #339933;">.</span>php$ http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.site.com/ [R=301,L]</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.captaincodemonkey.com/blog/2010/02/28/mod_rewrite-to-force-www-redirect-index-php-to-domain/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mod_rewrite to move one domain to another</title>
		<link>http://www.captaincodemonkey.com/blog/2009/08/10/mod_rewrite-to-move-one-domain-to-another/</link>
		<comments>http://www.captaincodemonkey.com/blog/2009/08/10/mod_rewrite-to-move-one-domain-to-another/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 00:07:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://www.captaincodemonkey.com/blog/?p=231</guid>
		<description><![CDATA[There may come a day when you need to move one domain&#8217;s content to another. This can easily be done with a little mod rewrite trickery in apache. Note the ^/ on the RewriteRule line, I have that because my server automatically adds the trailing slash, and if I don&#8217;t put this it will add [...]]]></description>
			<content:encoded><![CDATA[<p>There may come a day when you need to move one domain&#8217;s content to another.  This can easily be done with a little mod rewrite trickery in apache.</p>
<p>Note the ^/ on the RewriteRule line, I have that because my server automatically adds the trailing slash, and if I don&#8217;t put this it will add two slashes on the rewrite.  This just says, take everything after the first slash.  If your server dosen&#8217;t do this, then you can omit the /  and make it like: RewriteRule ^(.*).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p231code4'); return false;">View Code</a> LANGUAGE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2314"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p231code4"><pre class="language" style="font-family:monospace;">RewriteEngine On
RewriteRule ^/(.*)$ http://www.newdomain.com/$1 [R=301]</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.captaincodemonkey.com/blog/2009/08/10/mod_rewrite-to-move-one-domain-to-another/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mod_Rewrite Canonicalization Avoids Duplicate Content</title>
		<link>http://www.captaincodemonkey.com/blog/2009/08/09/mod_rewrite-canonicalization/</link>
		<comments>http://www.captaincodemonkey.com/blog/2009/08/09/mod_rewrite-canonicalization/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 23:42:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>

		<guid isPermaLink="false">http://www.captaincodemonkey.com/blog/?p=217</guid>
		<description><![CDATA[Apache&#8217;s mod_rewrite has been the bane of many. I think it is mostly the use of regular expressions that is the bane of many instead, but you get the idea. I want you to take a look at the following URLS: domain.com domain.com/ www.domain.com/ www.domain.com domain.com/index.html www.domain.com/index.html Do they all look the same to you? [...]]]></description>
			<content:encoded><![CDATA[<p>Apache&#8217;s mod_rewrite has been the bane of many.  I think it is mostly the use of regular expressions that is the bane of many instead, but you get the idea.</p>
<p>I want you to take a look at the following URLS:</p>
<p>domain.com<br />
domain.com/<br />
www.domain.com/<br />
www.domain.com<br />
domain.com/index.html<br />
www.domain.com/index.html</p>
<p>Do they all look the same to you? Well they are not the same to big G.  In fact, big G may just decide that you have duplicate content because it can see content on domain.com and domain.com/.</p>
<p>Now I don&#8217;t want to get into the dub dub dub vs non dub dub dub (also titled <a href="http://www.codinghorror.com/blog/archives/001109.html">The Great Dub Dub Dub Debate</a> by Jeff Atwood).</p>
<p>But what I will tell you is to pick one, and stick to it.</p>
<p>I found a great set of examples and want to pass them along, I have the basic gist of everything listed below, if this link ever goes down, but It is also worth reading the rest of the info on the page as well.</p>
<p>You can find the examples <a href="http://groups.google.com/group/only-validation/web/fix-canonical-issues-www-vs-non-www-and-more-on-apache-server?pli=1">here</a>:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p217code6'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2176"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code" id="p217code6"><pre class="html" style="font-family:monospace;">Options +FollowSymlinks
RewriteEngine on
RewriteBase /
&nbsp;
### re-direct index.html to root / ###
RewriteCond %{THE_REQUEST} ^.*\/index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
&nbsp;
### re-direct index.htm to root / ###
RewriteCond %{THE_REQUEST} ^.*\/index\.htm\ HTTP/
RewriteRule ^(.*)index\.htm$ /$1 [R=301,L]
&nbsp;
### re-direct index.php to root / ###
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
&nbsp;
### re-direct default.html to root / ###
RewriteCond %{THE_REQUEST} ^.*\/default\.html\ HTTP/
RewriteRule ^(.*)default\.html$ /$1 [R=301,L]
&nbsp;
### re-direct home.html to root / ###
RewriteCond %{THE_REQUEST} ^.*\/home\.html\ HTTP/
RewriteRule ^(.*)home\.html$ /$1 [R=301,L]
&nbsp;
### re-direct IP address to www
&nbsp;
### re-direct non-www to www
&nbsp;
### re-direct any parked domain to www of main domain
RewriteCond %{http_host} !^www.example.com$ [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc,L]
####
&nbsp;
############################ from here ########################################
&nbsp;
###### This group will not be needed by most websites - try without it first
### add a missing trailing slash to end of domain name or folder name
### ONLY in case the server does not compensate for it
### ONLY use it if needed - othewise remove this block of directives.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
&nbsp;
############################# to here ##########################################</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.captaincodemonkey.com/blog/2009/08/09/mod_rewrite-canonicalization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
