Darryl Hein
Darryl Hein

Reputation: 145097

Help with a rewrite rule that isn't working

I'm using the following rewrite rule, but I can't get it to work:

RewriteRule  ^rates/([a-z]+)\.php$  /rates.php?c_user_action=view_type&vehicle_type=$1  [QSA,L,NC]

The URL I'm using is http://www.example.com/rates/motorhomes.php

At the moment it's just going to /rates.php without a query string.

The weird this is if I change the rewrite expression to ^rates-([a-z]+)\.php$ and the URL to http://www.example.com/rates-motorhomes.php then it works.

I've used something similar on other sites/servers without any issue, but I can't figure out what I'm doing wrong here. This server is running Apache 2.2.

I know mod_rewrite is working, because the following 2 rules work:

RewriteRule  ^blah([a-z]+)\.php$  /rates.php?test=$1  [L]
RewriteRule  ^(.*)\.[\d]+\.(css|js)$  $1.$2  [L]

Upvotes: 1

Views: 95

Answers (1)

Gumbo
Gumbo

Reputation: 655489

It’s probably MultiViews that’s causing this behavior, mapping /rates/motorhomes.php to /rates.php/motorhomes.php before passing the request through to mod_rewrite. Try to disable it:

Options -MultiViews

Upvotes: 3

Related Questions