user198003
user198003

Reputation: 11151

RewriteRule directive redirect to unexisting page

I have trouble setting directives in .htaccess file. Trying to achieve that if visitor tries to open

http://localhost/occasions/anniversary/

... it have to call browse.php file in root directory, and to send 'anniversary' as one of the parameters.

I defined directive like:

RewriteRule ^/occasions/(.*)/$ http://localhost/browse.php?page=$1

... but it returns Page not found error.

Can you tell me why, and help me to solve this.

Thank you very much in advance!

Upvotes: 1

Views: 96

Answers (2)

ziesemer
ziesemer

Reputation: 28697

Just remove your first slash in your RewriteRule, like this:

RewriteRule ^occasions/(.*)/$ http://localhost/browse.php?page=$1

It won't match when using RewriteRule within .htaccess files, as this first slash isn't passed for evaluation.

Upvotes: 1

Pheonix
Pheonix

Reputation: 6052

Try it with Firefox + TamperData Addon and check the response to see where is the page redirecting instead of browse.html.

https://addons.mozilla.org/en-US/firefox/addon/tamper-data/

Upvotes: 1

Related Questions