Forum Moderators: phranque

Message Too Old, No Replies

Is there a Server Wide command for redirecting?

         

Jessica97

1:37 am on Nov 11, 2005 (gmt 0)

10+ Year Member



Hi, I'm trying to figure out the best way to go about correcting the problem of duplicate domains from being served on a server that currently recognizes both

the non www version of a site
ie: example.com and the www version ie: www.example.com

I've seen the sample code discussed here for how to do that in each individual htaccess file, but is there something that can be done system wide in the httpd.conf file on the server so that all domains will be redirected to their respective www versions?

I'm not very technical, so hopefully this has not been asked before. Did a seach here first but could only find samples of the modifying htaccess so thought I would ask some of the real experts here if there was a better, more efficient way of doing this without having to go in and fix each htaccess file manually and/or to change each htaccess file after site/s are created. Any suggestions would be very appreciated.

Thanks!

Jessica97

2:40 am on Nov 11, 2005 (gmt 0)

10+ Year Member



I should also add that I'm trying to fix the rewrites for several subdirectories on the server.

So far if I go in and manually change the htaccess code for the main/root directory than my redirect works, but if I try the same thing in a subdirectory

ie:

mysite.com/foldername

than I am getting all kinds of loops when trying to fix the www vs non www page issue. There are many subfolders on the sites and I was hoping not to have to manually go in and change each htaccess file, not to mention my "loop" problem when I do.

Anyone have any suggestions on how they deal with this? thanks again

jdMorgan

8:53 am on Nov 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are we talking about one domain here, or several?

The code you typically see posted here for redirecting www to non-www or vice-versa, should work if placed in the Web root .htaccess file. Most versions will work with a small modification if placed in the httpd.conf server config file.

You should not have to repeat the code in multiple .htaccess files in multiple subdirectories of the same site or domain. If you are finding that you need to do this, then your server configuration is either incorrect or 'very atypical.'

Jim