News:

Click here for Toll-Free Service for your business starting at $2.00 per month

Main Menu

htaccess rewrite

Started by x, December 16, 2005, 11:42:35 PM

Previous topic - Next topic

x

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

webzone (archived)

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]

x