homepage Welcome to WebmasterWorld Guest from 54.166.53.169
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
techy3482

5+ Year Member



 
Msg#: 3919032 posted 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:

http://www.example.com/?action=view/entries/3450entryid=3450

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

Any help with this would be greatly appreciated,

Rich

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

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3919032 posted 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...

Jim

techy3482

5+ Year Member



 
Msg#: 3919032 posted 1:08 pm on May 23, 2009 (gmt 0)

Cheers Jim,

Found the solution here:

[publib.boulder.ibm.com...]

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,

Rich

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3919032 posted 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