Wilco
Wilco

Reputation: 33364

What's wrong with this mod_rewrite rule?

Can anyone spot what is wrong with this URL rewrite? I can't get it to pass anything to GET (the script loads, but no parameters are passed):

RewriteRule ^archive(/(.*))?$ archive.php?action=$1 [QSA,L]

I want to map "archive/browse/" to "archive.php?action=browse".

Upvotes: 1

Views: 107

Answers (3)

Tyler Carter
Tyler Carter

Reputation: 61597

RewriteEngine On
RewriteRule ^archive/(.*)$  archive.php?action=$1 [QSA,L]

Would rewrite anything after /archive/ to archive.php?action=test/dir/path

Upvotes: 1

Gumbo
Gumbo

Reputation: 655785

You can get some conflicts when MultiViews is enabled. If it’s enabled, Apache first tries to find a file with a similar name to map the request to before passing it down to mod_rewrite. So a request of /archive/browse/ ends in /archive.php/browse/ before mod_rewrite can map it to your /archive.php?action=browse.

Try to disable it with:

Options -MultiViews

Upvotes: 3

Havenard
Havenard

Reputation: 27934

RewriteRule ^archive/([^/]*) archive.php?action=$1 [QSA,L]

Upvotes: 0

Related Questions