i'm trying to create a rewrite rule so that when someone tries to access a file in a directory (say http://www.domain.com/directory/file.html) it does a rewrite and gives them the contents of a specified php file with a that uses a query string (say http://www.domain.com/phpfile.php?file=file.html).
I wrote the following:
RewriteEngine on
RewriteRule ^/directory/(.*)$ phpfile.php?file=$1 [nc]
but i just keep getting a 404 error when i try http://www.domain.com/directory/file.html but it works fine when i try http://www.domain.com/phpfile.php?file=file.html.
any ideas? thanks
Never start a RewriteRule pattern with a /, that was your problem.
RewriteRule ^/directory/(.*)$ phpfile.php?file=$1 [nc] should be
RewriteRule ^directory/(.*)$ phpfile.php?file=$1 [nc]
thats smashing thanks :)