<?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>Chris Abernethy . com&#187; Apache</title>
	<atom:link href="http://www.chrisabernethy.com/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisabernethy.com</link>
	<description></description>
	<lastBuildDate>Wed, 31 Mar 2010 14:42:26 +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>Force Lower-Case URLs with mod_rewrite</title>
		<link>http://www.chrisabernethy.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.chrisabernethy.com%2Fforce-lower-case-urls-with-mod_rewrite%2F&amp;seed_title=Force+Lower-Case+URLs+with+mod_rewrite</link>
		<comments>http://www.chrisabernethy.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.chrisabernethy.com%2Fforce-lower-case-urls-with-mod_rewrite%2F&amp;seed_title=Force+Lower-Case+URLs+with+mod_rewrite#comments</comments>
		<pubDate>Fri, 25 Apr 2008 13:00:07 +0000</pubDate>
		<dc:creator>Brownoxford</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.chrisabernethy.com/?p=34</guid>
		<description><![CDATA[If you need your URLs to be all lower-case and you are running a standard LAMP stack, you're in luck. Apache's mod_rewrite can be used to 301-redirect all incoming requests to their lower-case counterparts with just a few configuration directives; see how it's done here.]]></description>
			<content:encoded><![CDATA[<p>You may find yourself in a situation at some point where you need to ensure that all access to your site is done using lower-case only. This may be because of SEO (avoiding duplicate content), or perhaps you want to ensure that you can seamlessly move between case-sensitive/insensitive operating systems. If you are running a standard LAMP stack, you're in luck. Apache's mod_rewrite can be used to 301-redirect all incoming requests to their lower-case counterparts with just a few configuration directives.</p>
<span id="more-34"></span>
<blockquote>
<b>10. Don't be Case Sensitive</b><br />
Since URLs can accept both uppercase and lowercase characters, don't ever, ever allow any uppercase letters in your structure. If you have them now, 301 them to all-lowercase versions to help avoid confusion. If you have a lot of type-in traffic, you might even consider a 301 rule that sends any incorrect capitalization permutation to its rightful home.<br />
<cite><a href="http://www.seomoz.org/blog/11-best-practices-for-urls" rel="nofollow" >http://www.seomoz.org/blog/11-best-practices-for-urls</a></cite>
</blockquote>

<p>It doesn't require much to rewrite URLs to lower-case, and the necessary configuration directives can be placed in either a virtualhost or .htaccess file. First, the RewriteEngine is enabled, and a custom RewriteMap called 'lc' is defined using the internal 'tolower' map. Next, a RewriteCond rule is used so that only URLs containing upper-case characters are rewritten. Finally, the actual RewriteRule is defined using the 'lc' RewriteMap that we just created to transform the captured URL to lower-case before 301-redirecting the user.</p>

<pre lang="apache">
RewriteEngine On
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
</pre>

<p>The following is the output from the RewriteLog that shows the processing for a request to /INDEX.PHP. Note that only a single upper-case letter needs to be present for the rewrite rule to be triggered. The log output clearly shows the rewrite rule being applied, the RewriteMap being referenced, and the 301 redirect taking place. The subsequent request for /index.php is also shown, where the rewrite condition does not match and the request is passed through.</p>

<pre line="1">
init rewrite engine with requested uri /INDEX.PHP
applying pattern '(.*)' to uri '/INDEX.PHP'
RewriteCond: input='/INDEX.PHP' pattern='[A-Z]' => matched
map lookup OK: map=lc key=/index.php -> val=/index.php
rewrite '/INDEX.PHP' -> '/index.php'
explicitly forcing redirect with http://test/index.php
escaping http://test/index.php for redirect
redirect to http://test/index.php [REDIRECT/301]
init rewrite engine with requested uri /index.php
applying pattern '(.*)' to uri '/index.php'
RewriteCond: input='/index.php' pattern='[A-Z]' => not-matched
pass through /index.php
</pre>




	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fforce-lower-case-urls-with-mod_rewrite%252F%26amp%3Bseed_title%3DForce%2BLower-Case%2BURLs%2Bwith%2Bmod_rewrite&amp;title=Force%20Lower-Case%20URLs%20with%20mod_rewrite&amp;bodytext=If%20you%20need%20your%20URLs%20to%20be%20all%20lower-case%20and%20you%20are%20running%20a%20standard%20LAMP%20stack%2C%20you%27re%20in%20luck.%20Apache%27s%20mod_rewrite%20can%20be%20used%20to%20301-redirect%20all%20incoming%20requests%20to%20their%20lower-case%20counterparts%20with%20just%20a%20few%20configuration%20directives%3B%20see%20how%20it%27s%20done%20here." title="Digg"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fforce-lower-case-urls-with-mod_rewrite%252F%26amp%3Bseed_title%3DForce%2BLower-Case%2BURLs%2Bwith%2Bmod_rewrite&amp;title=Force%20Lower-Case%20URLs%20with%20mod_rewrite" title="StumbleUpon"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" 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%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fforce-lower-case-urls-with-mod_rewrite%252F%26amp%3Bseed_title%3DForce%2BLower-Case%2BURLs%2Bwith%2Bmod_rewrite" title="Sphinn"><img src="http://www.chrisabernethy.com/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%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fforce-lower-case-urls-with-mod_rewrite%252F%26amp%3Bseed_title%3DForce%2BLower-Case%2BURLs%2Bwith%2Bmod_rewrite&amp;title=Force%20Lower-Case%20URLs%20with%20mod_rewrite&amp;notes=If%20you%20need%20your%20URLs%20to%20be%20all%20lower-case%20and%20you%20are%20running%20a%20standard%20LAMP%20stack%2C%20you%27re%20in%20luck.%20Apache%27s%20mod_rewrite%20can%20be%20used%20to%20301-redirect%20all%20incoming%20requests%20to%20their%20lower-case%20counterparts%20with%20just%20a%20few%20configuration%20directives%3B%20see%20how%20it%27s%20done%20here." title="del.icio.us"><img src="http://www.chrisabernethy.com/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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fforce-lower-case-urls-with-mod_rewrite%252F%26amp%3Bseed_title%3DForce%2BLower-Case%2BURLs%2Bwith%2Bmod_rewrite&amp;title=Force%20Lower-Case%20URLs%20with%20mod_rewrite&amp;source=Chris+Abernethy+.+com+&amp;summary=If%20you%20need%20your%20URLs%20to%20be%20all%20lower-case%20and%20you%20are%20running%20a%20standard%20LAMP%20stack%2C%20you%27re%20in%20luck.%20Apache%27s%20mod_rewrite%20can%20be%20used%20to%20301-redirect%20all%20incoming%20requests%20to%20their%20lower-case%20counterparts%20with%20just%20a%20few%20configuration%20directives%3B%20see%20how%20it%27s%20done%20here." title="LinkedIn"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fforce-lower-case-urls-with-mod_rewrite%252F%26amp%3Bseed_title%3DForce%2BLower-Case%2BURLs%2Bwith%2Bmod_rewrite&amp;t=Force%20Lower-Case%20URLs%20with%20mod_rewrite" title="Facebook"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisabernethy.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.chrisabernethy.com%2Fforce-lower-case-urls-with-mod_rewrite%2F&amp;seed_title=Force+Lower-Case+URLs+with+mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Configuring mod_rewrite for the Front-Controller Pattern</title>
		<link>http://www.chrisabernethy.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.chrisabernethy.com%2Fmod-rewrite-front-controller%2F&amp;seed_title=Configuring+mod_rewrite+for+the+Front-Controller+Pattern</link>
		<comments>http://www.chrisabernethy.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.chrisabernethy.com%2Fmod-rewrite-front-controller%2F&amp;seed_title=Configuring+mod_rewrite+for+the+Front-Controller+Pattern#comments</comments>
		<pubDate>Mon, 03 Dec 2007 20:41:52 +0000</pubDate>
		<dc:creator>Brownoxford</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.chrisabernethy.com/2007/12/03/mod-rewrite-front-controller/</guid>
		<description><![CDATA[When installing or creating a web application that implements the <a href="http://www.martinfowler.com/eaaCatalog/frontController.html">front controller</a> pattern on an apache server, it is common to use <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a> to redirect all traffic for non-existent resources to a the central dispatch file acting as the front controller. Depending on where your decide to place your mod_rewrite rules, the required syntax can differ.]]></description>
			<content:encoded><![CDATA[When installing or creating a web application that implements the <a href="http://www.martinfowler.com/eaaCatalog/frontController.html" rel="nofollow" >front controller</a> pattern on an apache server, it is common to use <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow" >mod_rewrite</a> to redirect all traffic for non-existent resources to a the central dispatch file acting as the front controller.

Depending on where your decide to place your mod_rewrite rules, the required syntax can differ. <span id="more-24"></span>The basic format of the rewrite configuration directives is as follows:

<pre lang="apache">
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . /index.php [L]
</pre>

In the preceding example, the rewrite engine is enabled, and two conditions are used to determine whether or not to run the rewrite rule. The first checks to see if the requested resource is not a file, and the second checks to see if the requested resource is not a directory. If both checks pass (ie: the resource does not exist), the rewrite rule will be executed and the file '/index.php' will be served.

Depending on what your application requires, your actual rewrite rule may differ slightly. For example, the <a href="http://framework.zend.com" rel="nofollow" >Zend Framework</a> requires that the original request be fed back into the central dispatch file like this:

<pre lang="apache">
RewriteRule ^(.*)$ /index.php/$1
</pre>

A common cause of problems is using the incorrect input in the <code>RewriteCond</code> directive. In all cases, it is correct to use either <code>%{SCRIPT_FILENAME}</code> or <code>%{REQUEST_FILENAME}</code> as they both contain the same text, but depending on where your rewrite rules are placed, you may need to prefix this with the contents of %{DOCUMENT_ROOT}. If your rules are placed in a per-directory context (<code>&lt;Directory&gt;</code>, <code>&lt;Location&gt;</code>, or <code>.htaccess</code> file), the document root is automatically prepended to the SCRIPT_FILENAME or REQUEST_FILENAME for you before the <code>RewriteCond</code> is processed. If your rules are located directly in a virtual host block, you will need to use the following syntax:

<pre lang="apache">
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-d
RewriteRule . /index.php [L]
</pre>





	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fmod-rewrite-front-controller%252F%26amp%3Bseed_title%3DConfiguring%2Bmod_rewrite%2Bfor%2Bthe%2BFront-Controller%2BPattern&amp;title=Configuring%20mod_rewrite%20for%20the%20Front-Controller%20Pattern&amp;bodytext=When%20installing%20or%20creating%20a%20web%20application%20that%20implements%20the%20front%20controller%20pattern%20on%20an%20apache%20server%2C%20it%20is%20common%20to%20use%20mod_rewrite%20to%20redirect%20all%20traffic%20for%20non-existent%20resources%20to%20a%20the%20central%20dispatch%20file%20acting%20as%20the%20front%20controller.%20Depending%20on%20where%20your%20decide%20to%20place%20your%20mod_rewrite%20rules%2C%20the%20required%20syntax%20can%20differ." title="Digg"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fmod-rewrite-front-controller%252F%26amp%3Bseed_title%3DConfiguring%2Bmod_rewrite%2Bfor%2Bthe%2BFront-Controller%2BPattern&amp;title=Configuring%20mod_rewrite%20for%20the%20Front-Controller%20Pattern" title="StumbleUpon"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" 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%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fmod-rewrite-front-controller%252F%26amp%3Bseed_title%3DConfiguring%2Bmod_rewrite%2Bfor%2Bthe%2BFront-Controller%2BPattern" title="Sphinn"><img src="http://www.chrisabernethy.com/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%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fmod-rewrite-front-controller%252F%26amp%3Bseed_title%3DConfiguring%2Bmod_rewrite%2Bfor%2Bthe%2BFront-Controller%2BPattern&amp;title=Configuring%20mod_rewrite%20for%20the%20Front-Controller%20Pattern&amp;notes=When%20installing%20or%20creating%20a%20web%20application%20that%20implements%20the%20front%20controller%20pattern%20on%20an%20apache%20server%2C%20it%20is%20common%20to%20use%20mod_rewrite%20to%20redirect%20all%20traffic%20for%20non-existent%20resources%20to%20a%20the%20central%20dispatch%20file%20acting%20as%20the%20front%20controller.%20Depending%20on%20where%20your%20decide%20to%20place%20your%20mod_rewrite%20rules%2C%20the%20required%20syntax%20can%20differ." title="del.icio.us"><img src="http://www.chrisabernethy.com/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.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fmod-rewrite-front-controller%252F%26amp%3Bseed_title%3DConfiguring%2Bmod_rewrite%2Bfor%2Bthe%2BFront-Controller%2BPattern&amp;title=Configuring%20mod_rewrite%20for%20the%20Front-Controller%20Pattern&amp;source=Chris+Abernethy+.+com+&amp;summary=When%20installing%20or%20creating%20a%20web%20application%20that%20implements%20the%20front%20controller%20pattern%20on%20an%20apache%20server%2C%20it%20is%20common%20to%20use%20mod_rewrite%20to%20redirect%20all%20traffic%20for%20non-existent%20resources%20to%20a%20the%20central%20dispatch%20file%20acting%20as%20the%20front%20controller.%20Depending%20on%20where%20your%20decide%20to%20place%20your%20mod_rewrite%20rules%2C%20the%20required%20syntax%20can%20differ." title="LinkedIn"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.chrisabernethy.com%2Ffeeder%2F%3FFeederAction%3Dclicked%26amp%3Bfeed%3DArticles%2B%2528RSS2%2529%26amp%3Bseed%3Dhttp%253A%252F%252Fwww.chrisabernethy.com%252Fmod-rewrite-front-controller%252F%26amp%3Bseed_title%3DConfiguring%2Bmod_rewrite%2Bfor%2Bthe%2BFront-Controller%2BPattern&amp;t=Configuring%20mod_rewrite%20for%20the%20Front-Controller%20Pattern" title="Facebook"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.chrisabernethy.com/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisabernethy.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fwww.chrisabernethy.com%2Fmod-rewrite-front-controller%2F&amp;seed_title=Configuring+mod_rewrite+for+the+Front-Controller+Pattern/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
