Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

RedirectMatch url issues


9:19 pm on Nov 11, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 11, 2003
votes: 0

RedirectMatch ^/anime/anime-by-title/(.*)\.html /anime/inex.php?cmd=_anime-by-title\&id=$1

I had expected the above line to redirect to:

Unless I comment out the "?" in the url param, I get a Forbidden Error, but when I comment out the "?" it redirects to:

Any ideas on how I can get the expected results using RedirectMatch

10:48 pm on Nov 11, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
votes: 0


Welcome to WebmasterWorld [webmasterworld.com]!

Well, you've found a nasty problem...

It seems that "&" has some special meaning when used in RedirectMatch substitution strings -- It is apparently a back-reference to the entire requested URI.

The only way I was able to get your Redirect to work properly was to use some character other than "&" to delimit the script calling parameters - In this case, I used "+".

RedirectMatch ^/anime/anime-by-title/(.*)\.html$ http://www.example.com/anime/index.php?cmd=_anime-by-title+id=$1

Note also that a canonical URL is required for the substitution -- It must begin with "http://...", and that special characters in the substitution string need not be escaped with a preceding backslash - the strange behaviour of "&" notwithstanding!

If you can adapt your script to accept some character other than "&" as a delimiter, the above should work. Otherwise, you may have to use mod_rewrite instead of mod_alias.


[edited by: jdMorgan at 2:06 pm (utc) on Nov. 12, 2003]

2:05 am on Nov 12, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 11, 2003
votes: 0

Thanks jdMorgan, but I already knew of the function of & in the URL of RedirectMatch, which is why I commented it out. What I got stuck on was having the character ? in the URL.

If I include a ?, the returned URL is (%-encoded) so i'll get something like www.domain.com/page.php%3ffoo=bar which causes a 403 Forbidden. I tried to comment out the ? character, but the comment gets commented, producing: www.domain.com/page.php%5c%3ffoo=bar, where %5c%3f = \\?, and the page gets parsed without the params.

Anyone know where to go from here?
How do I successfully use a ? in the URL of RedirectMatch and not get a 403 Forbidden?

Note: RedirectMatch works with a relative URL, Redirect(Temp¦Permanent)? does not.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members