<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1043638" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1043638</link>
    <description></description>
    <language>en</language>
          <item>
    <title>I always have a robts.txt to</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240631</link>
    <description> &lt;p&gt;I always have a robts.txt to keep bots in order, but humans and bad bots don&#039;t follow the robots.txt file.&lt;/p&gt;
 </description>
     <pubDate>Tue, 21 Apr 2009 00:00:50 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1240631 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>decibel.places wrote:
I&#039;m</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240630</link>
    <description> &lt;p&gt;&lt;div class=&quot;quote-msg&quot;&gt;&lt;div class=&quot;quote-author&quot;&gt;&lt;em&gt;decibel.places&lt;/em&gt; wrote:&lt;/div&gt;I&#039;m wondering about the paranoia level here. Presumably you&#039;re nervous about someone accessing includes to figure out vulnerabilities etc. &lt;/div&gt;It&#039;s not about security.&lt;br /&gt;
All my code is checked and limited to only allow what people can do through the normal usages.&lt;br /&gt;
So they could try to tamper with any file or includes and will get nowhere as a session or post/get variable wont be set or wont be allowable data, so they will be re-diverted.&lt;/p&gt;
&lt;p&gt;But some of the includes are purely for include purposes, such as a file that emails me upon a certain error. As this will happen very rarely I just have the email scripts in an include file, to avoid having code in the main file as 99% of the time it will be redundant.&lt;/p&gt;
&lt;p&gt;So while security isn&#039;t really an issue, people accessing this email file directly will send me an email, as with the other include files - one is a specific menu included on some pages, accessing it will show them the menu and nothing else. Again, it&#039;s not a security issue but they have no reason to be there.&lt;/p&gt;
&lt;p&gt;Just like your local corner shop doesn&#039;t want you going behind the counter. There is no need for you to be there.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;quote-msg&quot;&gt;&lt;div class=&quot;quote-author&quot;&gt;&lt;em&gt;decibel.places&lt;/em&gt; wrote:&lt;/div&gt;... if they can view the PHP source of the file that includes them&lt;/div&gt;They shouldn&#039;t be able to do that. If they do, they cannot bypass anything by knowing my var names or what I do as everything is checked in a strict manner.&lt;br /&gt;
That said, of course I wouldn&#039;t want to tempt fate &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 20 Apr 2009 23:59:00 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1240630 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>re: bots
wouldn&#039;t hurt to</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240628</link>
    <description> &lt;p&gt;re: bots&lt;/p&gt;
&lt;p&gt;wouldn&#039;t hurt to add a robots.txt file and meta tags for bots that behave...&lt;/p&gt;
 </description>
     <pubDate>Mon, 20 Apr 2009 21:20:45 +0000</pubDate>
 <dc:creator>decibel.places</dc:creator>
 <guid isPermaLink="false">comment 1240628 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Am I correct in thinking</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240626</link>
    <description> &lt;blockquote&gt;&lt;p&gt;Am I correct in thinking this will block robots too?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Bots can&#039;t get anywhere the average user can&#039;t get to.&lt;/p&gt;
 </description>
     <pubDate>Mon, 20 Apr 2009 21:00:01 +0000</pubDate>
 <dc:creator>pr0gr4mm3r</dc:creator>
 <guid isPermaLink="false">comment 1240626 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Hmm, double protection.
So</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240623</link>
    <description> &lt;p&gt;Hmm, double protection.&lt;/p&gt;
&lt;p&gt;So now I have a htaccess file in the incs dir like this:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;FILES ~ &amp;quot;\.*$&amp;quot;&amp;gt;&lt;br /&gt;Order allow,deny&lt;br /&gt;Deny from all&lt;br /&gt;&amp;lt;/FILES&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;That causes an Apache 403, which my main htaccess file in root redirects the user to the &quot;not found&quot; page.&lt;br /&gt;
I think telling people &quot;not found&quot; is better than &quot;permission denied&quot; as with the latter you have actually told them it exists and for these files, people don&#039;t need to know they exist.&lt;/p&gt;
&lt;p&gt;I also still leave the per file blocking as a backup&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SERVER&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;SCRIPT_NAME&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] == &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;/incs/the_filename.php&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;){ &lt;br /&gt;exit(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;Location: /not_found.php&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I think those two will be enough, cheers!&lt;br /&gt;
Am I correct in thinking this will block robots too?&lt;/p&gt;
 </description>
     <pubDate>Mon, 20 Apr 2009 19:28:00 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1240623 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>pr0gr4mm3r wrote:
I would</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240622</link>
    <description> &lt;p&gt;&lt;div class=&quot;quote-msg&quot;&gt;&lt;div class=&quot;quote-author&quot;&gt;&lt;em&gt;pr0gr4mm3r&lt;/em&gt; wrote:&lt;/div&gt;I would at least put in an .htaccess file with &lt;code&gt;Deny from all&lt;/code&gt; in the file.&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;obviously you meant in the folder/directory, not &quot;in the file&quot;&lt;/p&gt;
&lt;p&gt;greg and I know what you mean, but it could confuse n00bs &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I&#039;m wondering about the paranoia level here. Presumably you&#039;re nervous about someone accessing includes to figure out vulnerabilities etc. But the baddies will only know the filenames if they can view the PHP source of the file that includes them, not the rendered HTML sent to the browser. What is the likelihood of guessing a directory name AND a filename? &lt;/p&gt;
&lt;p&gt;Here is how Drupal secures the inc files in .htaccess:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;# Protect files and directories from prying eyes.&lt;br /&gt;&amp;lt;FilesMatch &amp;quot;\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp; Order allow,deny&lt;br /&gt;&amp;lt;/FilesMatch&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;try it: &lt;a href=&quot;http://drupal.org/includes/session.inc&quot; title=&quot;http://drupal.org/includes/session.inc&quot;&gt;http://drupal.org/includes/session.inc&lt;/a&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 20 Apr 2009 19:27:09 +0000</pubDate>
 <dc:creator>decibel.places</dc:creator>
 <guid isPermaLink="false">comment 1240622 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I just put my include files</title>
    <link>https://www.webmaster-forums.net/webmasters-corner/preventing-direct-access-include-files#comment-1240618</link>
    <description> &lt;p&gt;I just put my include files behind a folder that is not accessible by Apache.  That doesn&#039;t mean it has to be outside the web root, but I would at least put in an .htaccess file with &lt;code&gt;Deny from all&lt;/code&gt; in the file.&lt;/p&gt;
 </description>
     <pubDate>Mon, 20 Apr 2009 18:46:39 +0000</pubDate>
 <dc:creator>pr0gr4mm3r</dc:creator>
 <guid isPermaLink="false">comment 1240618 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
