Hi all,

I couldn't find a forum specific to Apache, so I'm putting it here if you don't mind. If you do mind, let me know and I'll move it someplace else 😉

I'm trying to set up a RedirectMatch directive in a .htaccess file that redirects people visiting a fake directory to a file containing the directory name in its query string - e.g.:

Someone goes to http://www.gazchap.com/gallery/shrewsbury and instead they get redirected to http://www.gazchap.com/gallery/index.php?id=shrewsbury

The first directive I tried was RedirectMatch /gallery/(.*) http://www.gazchap.com/gallery/index.php?$1 but this didn't work, not only because Apache 1.3 escapes the ? into %3F, but also because the regular expression matches that URL as well, causing Apache to go into a redirection loop.

I've gotten around the %3F problem by using a / instead of a ?, but the other problem remains.

I want to exclude real files ending in .php from the regular expression. I've tried this expression: /gallery/(.*)[.php] but it doesn't work.

Can anyone offer any pointers?

    Try using rewrite rules instead:

    RewriteEngine on
    RewriteRule /gallery/(.*) /gallery/index.php?id=$1

    see if that works 🙂

      Write a Reply...