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

    
Strange strange rewrite glitch
Adds full server path into URL
abates

10+ Year Member



 
Msg#: 3040572 posted 10:58 pm on Aug 9, 2006 (gmt 0)

I have a couple of mod_rewrite rules to redirect a domain and the www. variant of a subdomain to the proper subdomain. So [subdomain.domain.com...] redirects to [subdomain.domain.com...]

This works fine in practice except for one directory. For some reason it does something strange when it redirects:

[subdomain.domain.com...]
Redirects to [subdomain.domain.com...]

[subdomain.domain.com...]
Redirects to [subdomain.domain.com...]

It's only happening with this one subdirectory, not with any of the other subdirectories under subdirectory1.

I removed all of the .htaccess files from the directory structure leading up to that directory (including the one from my main domain) and only having one .htaccess for the subdomain which has the following rules in it:

RewriteEngine on
RewriteCond %{HTTP_HOST} otherdomain.org [NC]
RewriteRule (.*) [subdomain.domain.com...] [R=permanent,L]
RewriteCond %{HTTP_HOST} ^www.subdomain.domain.com [NC]
RewriteRule (.*) [subdomain.domain.com...] [R=permanent,L]

And the effect still occurs on subdirectory2. At this stage I'm stumped. I can't see anything in the rewrite rules which would behave differently for a particular subdirectory. My only theory is that the directory name is triggering some strange effect in Apache.

 

Caterham

10+ Year Member



 
Msg#: 3040572 posted 8:20 pm on Aug 10, 2006 (gmt 0)

Are you using the 2.2 branch? Because there is a bug in previus branches (conflict mod_dir/mod_rewrite), which is fixed since 2.1.

abates

10+ Year Member



 
Msg#: 3040572 posted 9:39 pm on Aug 10, 2006 (gmt 0)

Nope, I'm running 1.3.36. Is the problem in versions prior to version 2?

jdMorgan

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



 
Msg#: 3040572 posted 10:07 pm on Aug 10, 2006 (gmt 0)

Do you have access to the httpd.conf configuration file?

Jim

abates

10+ Year Member



 
Msg#: 3040572 posted 12:47 am on Aug 11, 2006 (gmt 0)

No, I don't unfortunately.

jdMorgan

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



 
Msg#: 3040572 posted 6:36 pm on Aug 11, 2006 (gmt 0)

Related thread: [webmasterworld.com...]

Look at the DirectoryIndex directive (if any) in .htaccess in the afflicted subdirectory, and be sure that the index filepath is a local URL-path, not including the DocumentRoot path.

A work around might be to add a rule to force a trailing slash on directory requests.

The double-slash in the incorrectly-rewritten URL smacks of a server misconfiguration.

Jim

abates

10+ Year Member



 
Msg#: 3040572 posted 11:51 pm on Aug 12, 2006 (gmt 0)

The problem turned out to be because in the subdirectory, I was using "RewriteOptions inherit" so that it would execute the rules in my main .htaccess file. Once I took that out, it worked fine.

I believe the reason is because when it came to evaluate:

RewriteCond %{HTTP_HOST} ^www.subdomain.domain.com [NC]
RewriteRule (.*) [subdomain.domain.com...] [R=permanent,L]

$1 ended up as the URI relative to the directory, not relative to the root of the subdomain, even though the rule being executed was in the .htaccess in the root directory of the subdomain.

Lesson learned. :)

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