title: Strange Forbidden 403 Error - Solution Needed
body: <p>I have a blog with a <code>add-post.php</code> page which contains a simple form with the action:</p>
  
  <pre><code>&lt;form id="form" action="add-post-php.php" method="POST" enctype="multipart/form-data"&gt;
  </code></pre>
  
  <p>I then have the file, <code>add-post-php.php</code> in the same folder as <code>add-post.php</code>.  So I enter the details of my blog into the form and press submit and get:</p>
  
  <blockquote>
    <p>Forbidden</p>
    
    <p>You don't have permission to access /add-post-php.php on this server.</p>
    
    <p>Additionally, a 404 Not Found error was encountered while trying to
    use an ErrorDocument to handle the request.</p>
  </blockquote>
  
  <ul>
  <li>I've tested this on my localhost and it works correctly</li>
  <li>The permission of the file is set at 0644, but I've also tried it at 0755, with no improvement.</li>
  <li>There is nothing wrong with my .htaccess file and there are no other .htaccess files in the directory.</li>
  <li>I've tried using the full url path in my form <code>action</code></li>
  </ul>
  
  <p>My <code>add-post-php.php</code> script in full is:</p>
  
  <pre><code>&lt;?php
  include("php/settings.php"); // Contains DB Connections
  ?&gt;
  &lt;?php
  $id= time();
  $month = date("m");
  $year = date("Y");
  $path = "images/posts/$year/$month/";
  
  $section = $_POST["section"];
  $category = $_POST["category"];
  $credit = $_POST["credit"];
  $title = ucwords($_POST["title"]);
  $text = $_POST["text"];
  $exclusive = $_POST["exclusive"];
  
  $added = date("Y-m-d H:i:s");
  
  $photo = $_FILES["photo"]["name"];
  $ext = substr(strrchr($photo, '.'), 1);
  ?&gt;
  &lt;?php
  $insert_sql = "INSERT INTO posts (id, section, category, credit, title, article, exclusive, added) VALUES('$id', '$section', '$category', '$credit', '$title', '$text', '$exclusive', '$added')";
  $insert_res = mysqli_query($con, $insert_sql);
  if(mysqli_affected_rows($con)&gt;0){
  move_uploaded_file($_FILES["photo"]["tmp_name"],"$path" . $id . "." . $ext);
  }
  else{
  echo "0";
  exit();
  };
  ?&gt;
  &lt;?php
  header("Location: post.php?id=$id");
  exit();
  ?&gt;
  </code></pre>
  
  <p>Here is my .htaccess:</p>
  
  <pre><code>Options -MultiViews
  
  DirectoryIndex posts.php
  
  RewriteEngine On
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d    
  
  RewriteRule ^posts/([0-9]+)/?$              posts.php?currentpage=$1 [NC,L,QSA]
  
  RewriteRule ^section/([\w-]+)/?$            section.php?section=$1 [NC,L,QSA]
  RewriteRule ^section/([\w-]+)/([0-9]+)/?$   section.php?section=$1&amp;currentpage=$2 [NC,L,QSA]
  
  RewriteRule ^posts/([\w-]+)/?$              posts.php?category=$1 [NC,L,QSA]
  RewriteRule ^posts/([\w-]+)/([0-9]+)/?$     posts.php?category=$1&amp;currentpage=$2 [NC,L,QSA]
  
  RewriteRule ^post/([0-9]+)/([\w-]+)/?$      post.php?id=$1&amp;title=$2 [NC,L,QSA]
  
  RewriteRule ^sites/([0-9]+)/?$              sites.php?currentpage=$1 [NC,L,QSA]
  
  RewriteRule ^posts posts.php
  RewriteRule ^section section.php
  RewriteRule ^sites sites.php
  
  RewriteRule ^about about.php
  RewriteRule ^advertise advertise.php
  RewriteRule ^subscribe subscribe.php
  </code></pre>
  
  <p>And folder structure:</p>
  
  <p><a href="https://i.stack.imgur.com/UubNo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UubNo.png" alt="enter image description here"></a></p>
  
  <p>I've checked the <code>php error log</code> and there's nothing suspicious there. Does anyone have any idea why I'm getting the Forbidden Error when the file clearly exists and it's permissions are correct?</p>