Forum Moderators: phranque

Message Too Old, No Replies

Why is my server redirecting automatically?

         

isorg

4:50 am on Dec 19, 2007 (gmt 0)

10+ Year Member



I have noticed that all the new directories on my server are behaving strangely. For example, if I type in http://www.example.com/test it automatically redirects to http://example.com/test/. It has taken out the "www". Why does this happen? It is happening on all the domains on my Apache/1.3.39.

It does not happen with http://www.example.com/test/index.html.

Where should I be looking for the culprit? The .htaccess files are empty. I am guessing this is a new feature in Apache, because I have only noticed this since upgrading to a new server.

phranque

11:32 am on Dec 19, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you should look for directives in the directory section(s) of your httpd.conf file(s).

jdMorgan

1:35 pm on Dec 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Likely a result of mod_dir being invoked to 'fix' the missing trailing slash, with example.com defined as the ServerName, and UseCanonicalName On

You can either turn off UseCanonicalName, or define www.example.com as the ServerName, with example.com as the ServerAlias.

Jim

isorg

6:25 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



Thanks a million, this was exactly the info I was looking for! :-)

The httpd.conf file states that UseCanonicalName is a new setting from Apache 1.3 onwards. My previous server used Apache 1.2 I think, so I did not experience this effect before. I turned UseCanonicalName OFF and the server is behaving nicely now!

Thanks again.

g1smd

12:01 am on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You may now have opened your site up to some new duplicate content issues.

You may well need to add a separate site-wide non-www to www redirect to ensure that non-www URLs cannot be indexed.

isorg

9:41 pm on Dec 20, 2007 (gmt 0)

10+ Year Member



Oh I see :-(

Can you recommend something I can put into httpd.conf that would do this?

g1smd

9:50 pm on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes. That code is published here several times per week, check back for recent posts that ask about www and non-www URLs. There are quite a few.

isorg

9:59 pm on Dec 20, 2007 (gmt 0)

10+ Year Member



Thanks, will look into it. :-)