Charlie Harding
Charlie Harding

Reputation: 685

RewriteRule not running

I have put a .htaccess file in httpdocs/test/, with two rules:

RewriteEngine On
RewriteRule ^test/reviews/([0-9]+)\-[A-Za-z1-9\-]$ /test/reviews.php?id=$1

DirectoryIndex reviews.php

The DirectoryIndex rule works, so I know the file is parsed. However, the address /test/reviews/123-Bose results in a 404 error. On my phpinfo file, under apache2hander, there is mod_rewrite next to Loaded Modules, so Rewrite has been loaded. Why doesn't /test/reviews/123-Bose get rewritten?

EDIT: I have to leave the .htaccess in the /test/ directory.

Thanks!

Upvotes: 0

Views: 49

Answers (1)

Niels Keurentjes
Niels Keurentjes

Reputation: 41958

Put the .htaccess file in the root folder, not in the subfolder, if you are going to specify the entire base path including test/ anyway. Also, add a base statement since you don't specify a leading slash:

RewriteEngine On
RewriteBase /
...your rules...

Upvotes: 1

Related Questions