Chris's Wiki :: blog/web/HtaccessRewrites Commentshttps://utcc.utoronto.ca/~cks/space/blog/web/HtaccessRewrites?atomcommentsDWiki2009-05-19T21:11:33ZRecent comments in Chris's Wiki :: blog/web/HtaccessRewrites.By Chris Siebenmann on /blog/web/HtaccessRewritestag:CSpace:blog/web/HtaccessRewrites:99d50f8813a5de893932ff04af6a9dd33772f3b5Chris Siebenmann<div class="wikitext"><p>I actively want my CGI applications that imitate directories to force a
redirection if the user asks for a URL without the slash, instead of just
presenting the normal top page.</p>
<p>(In some situations I think that you have to, in order to get relative
URLs in your generated page to act right, assuming you use relative URLs
at all.)</p>
</div>2009-05-19T21:11:33ZFrom 78.35.25.18 on /blog/web/HtaccessRewritestag:CSpace:blog/web/HtaccessRewrites:f663aa470015d809daa470ea6d6f127304a47018From 78.35.25.18<div class="wikitext"><p>Yes; I see that <code>PATH_INFO</code> canonicalisation as a feature. If you don’t need/want that, the rule actually gets simpler:</p>
<pre>
RewriteRule ^foo(/.*)?$ /cgis/my-cgi$1 [PT]
</pre>
<p>—<a href="http://plasmasturm.org">Aristotle Pagaltzis</a></p>
</div>2009-05-19T17:04:26ZBy Chris Siebenmann on /blog/web/HtaccessRewritestag:CSpace:blog/web/HtaccessRewrites:1f55da7a54ed98f464d9338e7a9b8ae9321d1cd0Chris Siebenmann<div class="wikitext"><p>That's a nicely clever rewrite rule. It does mean that <code>$PATH_INFO</code> will
always have a <code>/</code>, even if the user didn't supply one, but you probably
don't want to look at <code>$PATH_INFO</code> anyways, since I think that
<code>$REQUEST_URI</code> is both superior and always present.</p>
</div>2009-05-19T15:29:10ZFrom 78.35.25.18 on /blog/web/HtaccessRewritestag:CSpace:blog/web/HtaccessRewrites:2f75f427ca5dfa05d90da208bd8200d4aa1860daFrom 78.35.25.18<div class="wikitext"><pre>
RewriteRule ^foo(/(.*))?$ /cgis/my-cgi/$2 [PT]
</pre>
<p>—<a href="http://plasmasturm.org/">Aristotle Pagaltzis</a></p>
</div>2009-05-19T08:37:56Z