I know a little bit of mod_rewrite and have provided help here one or two times. But this is beyond me. Whenever a page is accessed, I want to the check whether the requested file exists in the current directory or the base parent directory. If not I want the request to be rewritten to another file. I got this much <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Code (markup): But I don't know how to check whether the file exists in the parent directory. I will give an example. suppose the user request for /test/path_to_file/filename.php, then the request should be rewritten to /index.php if either one of the following files do not exist /test/path_to_file/filename.php or /path_to_file/filename.php Can anyone please tell me how I can do it? Thanks
That would involve string manipulations in the rewrite conditions which is beyond the capabilities of .htaccess It can be done with server side scripting though, and it seems you already are using PHP so it shouldn't be much of a problem