homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

"&" Symbol Causing Mod Rewrite Errors
apache2 mod_rewrite errors using "&" symbol

 12:03 pm on May 23, 2009 (gmt 0)

Hey All

I've just upgraded to Apache2 and have hence had to update all of my rewrite rules.

For some reason the "&" symbol within the destination string is causing issues.

The system is copying part of the original short URL into the destination URL instead of remaining as an "&" symbol hence:

RedirectMatch 301 /entries/([0-9-]+)$ http://www.example.com/?action=view&entryid=$1

When forwards becomes:


I need a way of keeping "&" as "&" instead of becoming "/entries/3450"

Any help with this would be greatly appreciated,


[edited by: jdMorgan at 12:37 pm (utc) on May 23, 2009]
[edit reason] example.com [/edit]



 12:38 pm on May 23, 2009 (gmt 0)

This is not mod_rewrite code. RedirectMatch is a mod_alias directive.

Looking at the mod_alias documentation, one will find:
mod_alias is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.

However, I'd say you may have found an actual bug here, and you may wish to investigate the bug reports at Apache.org.

The form of your code brings up another question, though: Why do you wish to use a redirect and 'expose' the long, ugly, complex query-string URL to the client with a redirect instead of using the nice, short, original URL? I'd comment that instead of using an external client redirect here, an internal rewrite would seem to be more appropriate.

Unlike an external redirect, an internal rewrite would NOT tell the search engines to replace your short/pretty URL with the long one...



 1:08 pm on May 23, 2009 (gmt 0)

Cheers Jim,

Found the solution here:


the "&" requires a "\" before it in order to get it working thus:


All good.

Cheers for the mod_alias pointer - steered me in the right direction,



 6:40 pm on May 23, 2009 (gmt 0)

By why redirect to the ugly URL at all?

Surely you need a rewrite instead?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved