<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Tang&apos;s DW</title>
  <link>https://tangaroa.dreamwidth.org/</link>
  <description>Tang&apos;s DW - Dreamwidth Studios</description>
  <lastBuildDate>Sun, 02 Sep 2012 19:30:22 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>tangaroa</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/18831.html</guid>
  <pubDate>Sun, 02 Sep 2012 19:30:22 GMT</pubDate>
  <title>RemoveHandler .pl .cgi</title>
  <link>https://tangaroa.dreamwidth.org/18831.html</link>
  <description>&lt;p&gt;My website will have a directory where I do &lt;em&gt;not&lt;/em&gt; want CGIs to run. The obvious and wrong answer is to create an .htaccess file with &quot;Options -ExecCGI&quot;, but that causes the errors &quot;Access forbidden!&quot; and &quot;Options ExecCGI is off&quot; when I try to access a .pl file. For the next obvious and wrong solution, I tried renaming the file to &quot;.pl.txt&quot;. That did not work.&lt;/p&gt;

&lt;p&gt;Given that I would like to serve .pl files as plain text, I tried &quot;&lt;a href=&quot;http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addtype&quot;&gt;AddType&lt;/a&gt; text/plain .pl&quot;. &lt;a href=&quot;http://httpd.apache.org/docs/trunk/mod/mod_mime.html#removetype&quot;&gt;RemoveType&lt;/a&gt; also does not work; note that the docs say that this is what you use for this case. &lt;a href=&quot;http://httpd.apache.org/docs/current/rewrite/flags.html#flag_t&quot;&gt;RewriteRule \.pl$ - [T=text/plain]&lt;/a&gt; did not work; note, again, the docs say it should. 

&lt;p&gt;What did work was to add &quot;&lt;a href=&quot;http://httpd.apache.org/docs/2.2/mod/mod_mime.html#removehandler&quot;&gt;RemoveHandler&lt;/a&gt; .pl&quot;.&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=18831&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/18831.html</comments>
  <category>apache</category>
  <category>perl</category>
  <category>cgi</category>
  <category>webdev</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/18164.html</guid>
  <pubDate>Fri, 31 Aug 2012 06:01:58 GMT</pubDate>
  <title>.htaccess variables</title>
  <link>https://tangaroa.dreamwidth.org/18164.html</link>
  <description>&lt;p&gt;You can set variables inside an Apache .htaccess file. To copy directly from &lt;a href=&quot;http://www.aardvarkbusiness.net/chat/viewtopic.php?t=20437&quot;&gt;someone else&apos;s example&lt;/a&gt;: 

&lt;blockquote&gt;&lt;pre&gt;
 RewriteCond  %{REQUEST_URI}  ^/category_abc/ 
 RewriteRule .* - [E=cat_id:1] 

 RewriteCond  %{REQUEST_URI}  ^/category_def/ 
 RewriteRule .* - [E=cat_id:2]

 - The E= tells Apache we&apos;re creating a new ENV variable. 
 - The cat_id is the name of the variable we&apos;re creating 
 - The :x is the value of the variable (simple key : value syntax).
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;And from &lt;a href=&quot;http://www.askapache.com/htaccess/htaccess-fresh.html&quot;&gt;another example&lt;/a&gt;:

&lt;blockquote&gt;&lt;pre&gt;
RewriteCond %{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]
RewriteRule ^(.*)$ - [env=lang:%1]
Set lang var to URI
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)/(de|es|fr|it|ja|ru|en)/\ HTTP/ [NC]
RewriteRule ^(.*)$ - [env=lang:%2]
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;Environment variables are referenced as %{ENV:varname}. How they are used is another story. There are places you can&apos;t use them. &lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
# Make a variable for RewriteBase
RewriteCond &quot;/base_dir/&quot; ^(.*)$
RewriteRule ^(.*)$ - [E=RewriteBase:%1]
# Fails, causes an internal server error.
RewriteBase %{ENV:RewriteBase}
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;You can&apos;t do this either:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
# RequestPrefix is a previously declared variable. 
RewriteCond %{REQUEST_URI} ^%{ENV:RequestPrefix}(.*)$
RewriteRule ^(.*)$ - [E=RequestSuffix:%1]
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;A quick web search finds &lt;a href=&quot;http://board.issociate.de/thread/495372/Server-Variables_in_CondPattern_of_RewriteCond_directive.html&quot;&gt;someone claiming that rewrite condition patterns are compiled before variables are interpreted&lt;/a&gt;.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=18164&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/18164.html</comments>
  <category>apache</category>
  <category>computers</category>
  <category>webdev</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
