Jonathan Holvey Jonathan Holvey - 1 year ago 64
Apache Configuration Question

Any character match not working in Apache mod_rewrite RewriteRule

I'm trying to rewrite a URL on a website using Apache's


I have the following lines in a
file, which is in a folder
in the server's root directory:

RewriteEngine On
RewriteBase /foo/

RewriteRule ^(.+)$ index.php?id=$1 [NC,L]

The idea is that everything after
in the URL
is extracted and rewritten to
, which I thought should be pretty straightforward - this isn't my first time using

I've tested this successfully on, however, I'm finding that on my server it will only work if I use
instead of the wildcard
in the rule. Otherwise the
parameter returns

Is there a problem with my rule declaration? If not, what configuration could be causing this behaviour, and how can I override it?

Answer Source

Worth a shot in case other rewrites are interefering, or by any chance you are rewriting into index.php by accident:

RewriteRule ^(?!index.php)(.*) index.php?id=$1 [NC,L]