FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: x on December 16, 2005, 11:42:35 PM

Title: htaccess rewrite
Post by: x on December 16, 2005, 11:42:35 PM
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
Title: Re: htaccess rewrite
Post by: webzone (archived) on December 17, 2005, 12:37:22 AM
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]
Title: Re: htaccess rewrite
Post by: x on December 17, 2005, 01:40:43 AM
thats smashing thanks  :)