<?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>philihp.com &#187; phpMyID</title>
	<atom:link href="http://www.philihp.com/blog/tag/phpmyid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.philihp.com/blog</link>
	<description>I do things, and then I tell the internet about them.</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:40:30 +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>Redirecting with mod_rewrite without breaking OpenID</title>
		<link>http://www.philihp.com/blog/2009/redirecting-with-mod_rewrite-without-breaking-openid/</link>
		<comments>http://www.philihp.com/blog/2009/redirecting-with-mod_rewrite-without-breaking-openid/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 06:27:18 +0000</pubDate>
		<dc:creator>philihp</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[OpenID]]></category>
		<category><![CDATA[phpMyID]]></category>

		<guid isPermaLink="false">http://www.philihp.com/blog/?p=378</guid>
		<description><![CDATA[On philihp.com, I redirect the root address philihp.com to philihp.com/blog. I do this with mod_rewrite, since it&#8217;s much faster to do an HTTP Location header based redirect than to use an HTML meta tag redirect. I encountered a problem with this, though. I want to be able to authenticate with the identifier &#8220;philihp.com&#8221;. Not &#8220;openid.philihp.com&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p>On philihp.com, I redirect the root address philihp.com to philihp.com/blog. I do this with mod_rewrite, since it&#8217;s much faster to do an HTTP Location header based redirect than to use an HTML meta tag redirect. I encountered a problem with this, though.</p>
<p>I want to be able to authenticate with the identifier &#8220;philihp.com&#8221;. Not &#8220;openid.philihp.com&#8221;, not &#8220;philihp.com/openid&#8221;, just simply &#8220;philihp.com&#8221;, and I have it all setup using phpMyID to host locally, which is good. But rather than put all the server machinery for authenticating at my root level, I like to have it at &#8220;philihp.com/openid&#8221; (or elsewhere), and out of the way. OpenID has facility for doing this, since it&#8217;s almost always done; when a browser visits philihp.com, in the <code>HEAD</code> tags of the HTML, there&#8217;s the following:</p>
<pre>&lt;link rel="openid.server" href="<i>http://philihp.com/openid/</i>" /&gt;
&lt;link rel="openid.delegate" href="<i>http://philihp.com/</i>" /&gt;
</pre>
<p>Where the <code>openid.server</code> specifies where the machinery is for taking care of the authentication, and the <code>openid.delegate</code> specifies what the claimed identifier is. What happens when you go to somewhere like <a href="http://twitterfeed.com">twitterfeed.com</a>, when you try to authenticate there the server itself goes to the URL you give it, looks at the <code>HEAD</code> tags of the HTML it sees there, and forwards the end user to the <code>openid.server</code> specified. The problem I had is that when the server goes to philihp.com, it&#8217;s being redirected from mod_rewrite to blog/ because of <a href="/blog/2009/01/redirect-root-path-to-blog-directory/">this thing</a>. This is bad, because it causes my claimed identifier to be &#8220;philihp.com/blog/&#8221; instead of just &#8220;philihp.com&#8221;.</p>
<p>I wasn&#8217;t the first person to have this problem, though. <a href="http://qedx.com/blog/redirecting-without-breaking-openid/2009/01/07/">Haris bin Ali</a> and <a href="http://willnorris.com/2008/12/challenges-in-changing-my-openid">Will Norris</a> found a solution with PHP that checks the HTTP headers and redirects based on them. Below these have been adapted to RewriteCond rules, which would get evaluated before PHP or any other platform your site runs on (so long as it&#8217;s still Apache).</p>
<pre>RewriteCond %{HTTP_USER_AGENT} !openid [NC]
RewriteCond %{HTTP_USER_AGENT} !^$
RewriteCond %{HTTP_ACCEPT} !application/xrds+xml [NC]
RewriteRule ^$ /blog/ [R,L]</pre>
<p>These say &#8220;Redirect empty requests (requests for root) to /blog/, unless the User-Agent header has &#8220;openid&#8221; in it, or is blank, or the Accept header contains &#8220;application/xrds+xml&#8221;"; which are all going to be characteristic of a request coming from an OpenID consumer, and not from a normal browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.philihp.com/blog/2009/redirecting-with-mod_rewrite-without-breaking-openid/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

