I want to achieve this redirection using .htaccess or anything which can get this thing done. If anyone visit www.example.com/abc/myfile.html (the file does not exist on server) The redirect should pass the "/abc/myfile.html" portion of the url to a php script like this: www.example.com/myscript.php?url=abc/myfile.html Is this possible ??
Something like this should do the trick : RewriteRule ^([-_a-zA-Z0-9]+).html$ /myscript.php?url=$1 [L] Code (markup):
In my opinion the previous example is not correct. What you need to check whether the file exists, and if it does not pass the whole URI as a parameter to the php script RewriteEngine On # check if requested file exists RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f # if not, pass it to index.php RewriteRule ^(.*) index.php?page=$1 [QSA] # QSA preserves the query