.htaccess use file in place of

if a file does not exist, I need .htaccess to mod rewrite an alt file in place of that missing file as if it were in directory all along.
When I use the following, the 'wtf.php' file processes from the folder its currently in, I need it to process from the suppose location where it is missing.

RewriteEngine On
RewriteCond $1 !^files
RewriteCond %{REQUEST_URI} wtf.php
RewriteRule .* ../wtf.php/

    Maybe add a query string parameter to the actual file being called that tells it what directory to use, then in the script itself, use chdir() to move to that directory if it's provided?

      I came up with...

      RewriteEngine On
      RewriteRule index.php$ zindex.php

      /index.php will execute /zindex.php

      /index.php?query=string will execute /zindex.php //$_GET['query'] === 'string'

      / will execute /zindex.php

      /folder/index.php will execute /folder/index.php

      however Im not sure how to access the files on root dir

        Write a Reply...