Forum Moderators: phranque

Message Too Old, No Replies

Apache Redirect going crazy.

Duplicates file name or something...

         

JAB Creations

1:27 pm on Jan 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd like to redirect doing essentially the following...
Redirect permanent /music http://www.example.com/music/music-playlist-2.6.php

However it creates a weird URL (broken to avoid creating a horizontal scrollbar)...

http://www.example.com/music/music-playlist-2.6.php/mus
ic-playlist-2.6.php/music-playlist-2.6.php/music-playli
st-2.6.php/music-playlist-2.6.php/music-playlist-2.6.ph
p/music-playlist-2.6.php/music-playlist-2.6.php/music-p
laylist-2.6.php/music-playlist-2.6.php/music-playlist-2
.6.php/music-playlist-2.6.php/music-playlist-2.6.php/mu
sic-playlist-2.6.php/music-playlist-2.6.php/music-playl
ist-2.6.php/music-playlist-2.6.php/music-playlist-2.6.p
hp/music-playlist-2.6.php/music-playlist-2.6.php/

jdMorgan

3:06 pm on Jan 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because the 'new' URL matches the prefix for the 'old' one to be redirected, and because each redirect results in a new HTTP request, the Redirect directive is doing exactly what you told it to do -- Obviously not what you wanted.

Your directive says "Redirect URLs /music<anything> to /music/music-playlist-2.6.php<anything>", as described in the Redirect directive documentation in Apache mod_alias [httpd.apache.org].

A better solution is to use RedirectMatch [httpd.apache.org], where the exact URL to be redirected can be specified using a regular-expressions pattern:


RedirectMatch 301 ^/music/?$ http://www.example.com/music/music-playlist-2.6.php

As shown, this redirects only "/music" or "/music/" to "www.example.com/music/music-playlist-2.6.php"

Jim