Welcome to WebmasterWorld Guest from 50.17.74.162

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite $1 not carrying last /

     

wkitty42

10:40 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



i'm redirecting calls to an old directory to a new directory... here's the ruleset that i'm using...


#handle moving requests for /files4 to /files2 since moving files on F: to G:
RewriteRule files4/(.*) http://www.example.com/files2/$1[R=301,L]

when the original request comes in as /files2/foo/ i get two redirects in my logfile... one to /files4/foo and then a second to /files4/foo/ because foo is a directory and there should have been a trailing / anyway... so, why doesn't $1 or (.*) carry that training slash when it is there in the original request?

jdMorgan

3:30 pm on Feb 25, 2005 (gmt 0)

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



This sounds a lot like another recent post [webmasterworld.com], and my answer would be the same: Some other code in httpd.conf or .htaccess is interfering.

Also, check to be sure that UseCanonicalName is Off, or that you have specified a correct canonical name.

I suppose that content negotiation could also be interfering; Disable it unless you need it (using Options -Multiviews in .htaccess if you don't have httpd.conf access).

Jim

wkitty42

11:56 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



jd,

yeah, i had read that thread and it does seem kinda similar... the reason i didn't jump in on that one is that the situations are exactly backwards... i'll have to go checking and see what's up... i don't think it is anything in .htaccess on my system, though... i don't have any code there to do that type of stuff, that i know of... however, it could be something with mod_spelling or such... i don't recall my canocial names setting... not sure i have one set but i do use multiviews for various things...

at this time, it is a mystery... but it won't be for long as those old urls are removed from the search engines... after some more months, i'll be removing that redirect code and won't have that problem any more...

oh well... i thought that it might be something easy that i wasn't aware of WRT (.*) and $1 usages and such...

[aside: glad to see you still here! i see you've moved up in the ranks a bit, too... congrats on the mod status ;)]