Forum Moderators: phranque

Message Too Old, No Replies

non www. to non www questions

         

editordude

9:46 am on Sep 22, 2005 (gmt 0)

10+ Year Member



I have a few questions regarding the issue of redirecting www. url to non wwwl url and vice versa.

1. Which method do you use and why? ( do you redirect www.domain.com to domain.com or other way around and what are your reasons? )

2. What are the pro's and cons of creating such .htaccess rules? ( the good sides and downsides to not only each style but creating any kind of redirect or not ).

Would greatly appreciate any help. Is there a term which describes this process or re-direct as a google search off "non www" and such doesn't help much.

Thank you

editordude

10:13 am on Sep 22, 2005 (gmt 0)

10+ Year Member



Can't find the edit the above post ( does this forum allow us to edit our own posts? ). I do have one important question I forgot to ask:

3. Say I use a code like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteRule (.*) [domain.com...] [R=301,L]

I have another site which is an add-on domain on my cpanel and the site is in the folder say: domain.com/site2/

If the .htaccess code is in domain.com/ .. why isn't the /site2/ folder effected. ( as it uses anotherdomain.com and the .htaccess in a folder above checks if the url is anything but www.domain.com

Hope I'm making sense.
Thanks

editordude

11:21 pm on Sep 24, 2005 (gmt 0)

10+ Year Member



Anyone able to help?

jdMorgan

12:16 am on Sep 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Generally, the choice between implementation methods depends on what Apache modules or server-side scripting languages you are most familiar/comfortable with, and the complexity of the redirect. As soon as you start adding exceptions of special conditions to redirects, simple modules like mod_alias run out of power and you'll need to use mod_rewrite. If these exceptions and/or special conditions get very complex, then you may need to go to a scripted solution.

Add-on domains added via control panel are implemented by adding code to httpd.conf. Because requests for these domains are sent directly to the subdirectory in which the pages for that domain are stored, the .htaccess file for your main domain is not processed for these requests.

Jim