<?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>Nomulous Blog &#187; internal server error</title>
	<atom:link href="http://nomulous.com/blog/tag/internal-server-error/feed/" rel="self" type="application/rss+xml" />
	<link>http://nomulous.com/blog</link>
	<description>Caveat Lector</description>
	<lastBuildDate>Mon, 20 Feb 2012 19:30:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to avoid looping in mod_rewrite redirection</title>
		<link>http://nomulous.com/blog/how-to-avoid-looping-in-mod_rewrite-redirection/</link>
		<comments>http://nomulous.com/blog/how-to-avoid-looping-in-mod_rewrite-redirection/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 05:40:54 +0000</pubDate>
		<dc:creator>nomulous</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[internal server error]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[mod rewrite]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[request uri]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[rewritecond]]></category>

		<guid isPermaLink="false">http://nomulous.com/blog/?p=66</guid>
		<description><![CDATA[When redirecting things to a new location that fits the original rewrite pattern, you end up with a recursive feedback loop and all you get is an error. If you specified a URL scheme and a domain in your rewrite (meaning that the redirection is visible to the browser) you&#8217;ll see the error in your [...]]]></description>
			<content:encoded><![CDATA[<p>When redirecting things to a new location that fits the original rewrite pattern, you end up with a recursive feedback loop and all you get is an error. If you specified a URL scheme and a domain in your rewrite (meaning that the redirection is visible to the browser) you&#8217;ll see the error in your browser saying something along the lines of &#8220;the page tried to redirect too many times&#8221;. Otherwise, the redirection will be internal, and you&#8217;ll get your server&#8217;s 500 Internal Server Error page.</p>
<p style="text-align: center;"><a href="http://nomulous.com/blog/wp-content/uploads/2009/06/redirect_loop_safari.png"><img class="aligncenter size-full wp-image-71" title="redirect_loop_safari" src="http://nomulous.com/blog/wp-content/uploads/2009/06/redirect_loop_safari.png" alt="redirect_loop_safari" width="478" height="236" /></a></p>
<p>So, how do you avoid it? Well, say you wanted to redirect some regex (regular expression) pattern to the your index page, say index.php, but it turns out that &#8220;index.php&#8221; actually matches your pattern, so index.php redirects to index.php which redirects to index.php, and so on, and so forth.</p>
<p>To prevent this, simply add a RewriteCond that checks the REQUEST_URI to make sure it doesn&#8217;t match the string that you redirect to. The following is an example.</p>
<p><code>RewriteCond %{REQUEST_URI} !^/?index.php$<br />
RewriteRule ^(regex|goes|here)$ /index.php</code></p>
<p>Just make sure the regex in the first part does <em>not</em> match any of the pages you want to redirect, and that&#8217;s it! You&#8217;re done.</p>
<p>Best of luck on getting this to work the way you want it to, and happy web developing!</p>
]]></content:encoded>
			<wfw:commentRss>http://nomulous.com/blog/how-to-avoid-looping-in-mod_rewrite-redirection/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

