Strange redirect when missing trailing slash

This is a discussion on Strange redirect when missing trailing slash within the Apache Web Server forums, part of the Web Server and Related Forums category; I have approx. 60 domains hosted under one cPanel account on a leased dedicated server (CentOS 4.4 i686, Apache ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-02-2006
PseudoMega
 
Posts: n/a
Default Strange redirect when missing trailing slash

I have approx. 60 domains hosted under one cPanel account on a leased
dedicated server (CentOS 4.4 i686, Apache 1.3.37). So there is a
parent domain, and the rest are subdomains of the parent domain.

directory structure in of public_html is like this:

/public_html/html of parent domain
/public_html/domain1/html of domain1
/public_html/domain2/html of domain2

.... and so on.

So "domain1.com" is technically "domain1.parentdomain.com"

If I go to "domain1.com/folder/" (with a trailing slash), everything is
fine.
If I go to "domain1.com/folder" (without a trailing slash), I am
redirected to domain1.parentdomain.com/folder/ (with a trailing slash).

So apache checks to see if "/folder" is a file or a directory, sees
that it is a directory, then does a 301 to "/folder/" (with a trailing
slash), and the domain part gets rewritten into the subdomain format.

In my searching for a resolution, I've noticed other people referring
to these settings in httpd.conf:

UseCanonicalName = on
ServerName = www.parentdomain.com

If you'd like to see this all in action, check out
www.cuppys.com/encyclopedia/. If you remove the trailing slash, you
will be redirected to cuppys.medinaenterprises.com/encyclopedia/

Is there maybe a rewrite rule I could use to subvert this?

  #2 (permalink)  
Old 12-02-2006
HansH
 
Posts: n/a
Default Re: Strange redirect when missing trailing slash

"PseudoMega" <pseudomega@gmail.com> schreef in bericht
news:1165022702.768132.214420@n67g2000cwd.googlegr oups.com...
>I have approx. 60 domains hosted under one cPanel account on a leased
> dedicated server (CentOS 4.4 i686, Apache 1.3.37). So there is a
> parent domain, and the rest are subdomains of the parent domain.
>
> directory structure in of public_html is like this:
>
> /public_html/html of parent domain
> /public_html/domain1/html of domain1
> /public_html/domain2/html of domain2
>
> ... and so on.
>
> So "domain1.com" is technically "domain1.parentdomain.com"
>
> If I go to "domain1.com/folder/" (with a trailing slash), everything is
> fine.
> If I go to "domain1.com/folder" (without a trailing slash), I am
> redirected to domain1.parentdomain.com/folder/ (with a trailing slash).
>
> So apache checks to see if "/folder" is a file or a directory, sees
> that it is a directory, then does a 301 to "/folder/" (with a trailing
> slash), ...

That's mod_dir doing its job
http://httpd.apache.org/docs/2.0/mod...directoryslash

> ... and the domain part gets rewritten into the subdomain format.

Wonder whether 'UseCanonicalName = off' may solve that
http://httpd.apache.org/docs/2.0/mod...ecanonicalname

> If you'd like to see this all in action, check out
> www.cuppys.com/encyclopedia/. If you remove the trailing slash, you
> will be redirected to cuppys.medinaenterprises.com/encyclopedia/

I guess there is some rewrite interfering with the request too.
Might look like
RewriteCond %{HTTP_HOST} ([^\.]+).com$
RewriteRule (.*) /%1$1 [PT,QSA]

> Is there maybe a rewrite rule I could use to subvert this?

Show us the current rules and conditions first.

HansH


  #3 (permalink)  
Old 12-02-2006
PseudoMega
 
Posts: n/a
Default Re: Strange redirect when missing trailing slash

> > ... and the domain part gets rewritten into the subdomain format.
>
> Wonder whether 'UseCanonicalName = off' may solve that
> http://httpd.apache.org/docs/2.0/mod...ecanonicalname


Well, I turned it off and it seems that my problem is resolved...

I'll need to contact the sysad who compiled this machine to make sure
there wasn't a good reason for having it turned on.

Thanks for the suggestion Hans!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:14 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0