title: PHP Routing on Apache Server
body: <p>The following code, in <code>index.php</code>, gives the expected routing behaviour when I run it using the built in php web server:</p>
  
  <pre><code>&lt;?php
  $request = $_SERVER['REQUEST_URI'];
  switch ($request) {
      case '/' :
          echo 'This is the Home Page';
          break;
      case '/about' :
          echo ' This is the About Page';
          break;
      default:
          echo 'Resource not Found (404)';
          break;
  }
  </code></pre>
  
  <p>The same code uploaded to my Ionos Linux web server running Apache does not work: If I access the root directory from a firefox browser (eg <a href="http://mywebsites.org.uk/root-directory" rel="nofollow noreferrer">http://mywebsites.org.uk/root-directory</a>) I get <code>Resource not Found (404)</code>in the browser. If I append something to the URL (eg <a href="http://mywebsites.org.uk/root-directory/about" rel="nofollow noreferrer">http://mywebsites.org.uk/root-directory/about</a>) the browser just gives some page with advertising on which is what you get when there is nothing corresponding to that path on the server). Same happens if you change 'about' for any other word.</p>
  
  <p>I tried with the following <code>.htaccess</code> file in the root directory along with the <code>index.php</code> file:</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.+)$ index.php [QSA,L]
  </code></pre>
  
  <p>Now I get the same result with <a href="http://mywebsites.org.uk/root-directory" rel="nofollow noreferrer">http://mywebsites.org.uk/root-directory</a>. That shows <code>Resource not Found (404)</code> in the browser as before. However, with <a href="http://mywebsites.org.uk/root-directory/about" rel="nofollow noreferrer">http://mywebsites.org.uk/root-directory/about</a> or any word substituting 'about' I now get an error message in the browser:</p>
  
  <blockquote>
    <p>Multiple Choices
    The document name you requested (/index.php) could not be found on this server. However, we found documents with names similar to the one you requested.
    Available documents:
    /index.html (common basename)</p>
  </blockquote>
  
  <p>When I click on <code>index.html</code> (which is hyperlinked) I find that it is in the directory above the root-directory with the <code>index.php</code> file in it. Ie it is in the mywebsites.org.uk directory. Obviously it is not what I am after.</p>
  
  <p>I also tried replacing the content of the <code>.htaccess</code> file with <code>FallbackResource /index.php</code>. The result was the same as when I had no <code>.htaccess</code> file at all which I described earlier.</p>
  
  <p>I am finding it very difficult to understand my Ionos web server. I do not know if I can change configuration files for Apache or not and I have little understanding of .htaccess files. I have thought of changing to AWS over this issue as the documentation there seems more thorough. However I would prefer not to change if I can sort this issue out. Basically I want to be able to build a PHP router on my Ionos server which runs Apache., </p>