Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite $1 not carrying last /

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

Preferred Member

10+ Year Member

joined:May 14, 2003
votes: 0

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?

3:30 pm on Feb 25, 2005 (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

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).


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

Preferred Member

10+ Year Member

joined:May 14, 2003
votes: 0


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 ;)]


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members