<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Control htaccess Basic Authentication with PHP and mod_rewrite</title>
	<atom:link href="http://www.askapache.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.askapache.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Wed, 18 Nov 2009 23:28:48 -0500</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jaime</title>
		<link>http://www.askapache.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-74136</link>
		<dc:creator>Jaime</dc:creator>
		<pubDate>Sat, 16 May 2009 00:43:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-74136</guid>
		<description>Ok, I got it to work with the following code. I use mine to protect mp3 files on my site. 

&lt;pre&gt;$fqfile=$absolutepath/$filename;
if (file_exists($fqfile))
{
 header(&quot;Cache-Control: public, must-revalidate&quot;);
 header(&quot;Pragma: hack&quot;); // not sure what this does but it works
 header(&quot;Content-Type: &quot; . $mm_type);
 header(&quot;Content-Length: &quot; .(string)(filesize($fqfile)) );
 header(&#039;Content-type: audio/mpeg&#039;);
 //header(&#039;Content-Disposition: attachment; filename=&quot;&#039;.$filename.&#039;&quot;&#039;);
 header(&quot;Content-Transfer-Encoding: binary\n&quot;);
 readfile($fqfile);
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Ok, I got it to work with the following code. I use mine to protect mp3 files on my site. </p>
<pre>$fqfile=$absolutepath/$filename;
if (file_exists($fqfile))
{
 header("Cache-Control: public, must-revalidate");
 header("Pragma: hack"); // not sure what this does but it works
 header("Content-Type: " . $mm_type);
 header("Content-Length: " .(string)(filesize($fqfile)) );
 header(&#039;Content-type: audio/mpeg&#039;);
 //header(&#039;Content-Disposition: attachment; filename="&#039;.$filename.&#039;"&#039;);
 header("Content-Transfer-Encoding: binary\n");
 readfile($fqfile);
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaime</title>
		<link>http://www.askapache.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-73567</link>
		<dc:creator>Jaime</dc:creator>
		<pubDate>Wed, 13 May 2009 00:56:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-73567</guid>
		<description>Funny. I have the EXACT same problem as alfred. I am trying to protect mp3/etc.. files on my site with a simple php session check routine, though after it succeeds I am lost as to how to resume the normal GET operation. 

Any help or pointers would be greatly appreciated.</description>
		<content:encoded><![CDATA[<p>Funny. I have the EXACT same problem as alfred. I am trying to protect mp3/etc.. files on my site with a simple php session check routine, though after it succeeds I am lost as to how to resume the normal GET operation. </p>
<p>Any help or pointers would be greatly appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Drummond</title>
		<link>http://www.askapache.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-37070</link>
		<dc:creator>John Drummond</dc:creator>
		<pubDate>Tue, 11 Mar 2008 10:35:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-37070</guid>
		<description>At last, I found this at AlistApart: &lt;a href=&quot;http://alistapart.com/articles/succeed&quot; rel=&quot;nofollow&quot;&gt;How to Succeed With URLs&lt;/a&gt;

&lt;pre&gt;
session_start();
if (session_is_registered(pdb_sessname))
{
  if(file_exists($DOCUMENT_ROOT.$REQUEST_URI) and
($SCRIPT_FILENAME!=$DOCUMENT_ROOT.$REQUEST_URI) and ($REQUEST_URI!=&quot;/&quot;))
  {
    $url=$REQUEST_URI;
    include($DOCUMENT_ROOT.$url);
    exit();
  }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>At last, I found this at AlistApart: <a href="http://alistapart.com/articles/succeed" rel="nofollow">How to Succeed With URLs</a></p>
<pre>session_start();
if (session_is_registered(pdb_sessname))
{
  if(file_exists($DOCUMENT_ROOT.$REQUEST_URI) and
($SCRIPT_FILENAME!=$DOCUMENT_ROOT.$REQUEST_URI) and ($REQUEST_URI!="/"))
  {
    $url=$REQUEST_URI;
    include($DOCUMENT_ROOT.$url);
    exit();
  }
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alfred</title>
		<link>http://www.askapache.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-21643</link>
		<dc:creator>Alfred</dc:creator>
		<pubDate>Fri, 05 Oct 2007 06:59:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/tricks-for-controlling-htaccess-basic-authentication-with-php-and-mod_rewrite.html#comment-21643</guid>
		<description>I would like to implement the AddHandler tip to restrict access to CONTENT.HTML (and other HTML files) to authorised users.

Content of .htaccess:

&lt;blockquote cite=&quot;&quot;&gt;
&lt;code&gt;
AddHandler mywrapper .html
Action mywrapper /secure.php
&lt;/code&gt;
&lt;/blockquote&gt;

Contents of secure.php:
&lt;blockquote cite=&quot;&quot;&gt;
&lt;code&gt;
session_start();
if(!$_SESSION[&#039;authorised&#039;]){
  die(&#039;You are not authorised to access this content!&#039;);
} else {
  // THIS IS WHERE I DONT KNOW WHAT TO DO
}
&lt;/code&gt;
&lt;/blockquote&gt;

How do I get CONTENT.HTML to display if $_SESSION[&#039;authorised&#039;] is &lt;code&gt;true&lt;/code&gt;?</description>
		<content:encoded><![CDATA[<p>I would like to implement the AddHandler tip to restrict access to CONTENT.HTML (and other HTML files) to authorised users.</p>
<p>Content of .htaccess:</p>
<blockquote cite=""><p>
<code>AddHandler mywrapper .html<br />
Action mywrapper /secure.php</code>
</p></blockquote>
<p>Contents of secure.php:</p>
<blockquote cite=""><p>
<code>session_start();<br />
if(!$_SESSION[&#039;authorised&#039;]){<br />
  die(&#039;You are not authorised to access this content!&#039;);<br />
} else {<br />
  // THIS IS WHERE I DONT KNOW WHAT TO DO<br />
}</code>
</p></blockquote>
<p>How do I get CONTENT.HTML to display if $_SESSION['authorised'] is <code>true</code>?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
