- - - - -

Domain redirect problem


  • Please log in to reply
4 replies to this topic

#1 NyteOwl

NyteOwl

    36 Bits forever!

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 1,902 posts

Posted 06 March 2012 - 04:02 PM

I wonder if anyone might have any suggestions on the following problem.

I have an established domain exampledomain.ca which is an addon to basedomain.ca.

I have the following in htaccess to redirect variations and it has been working perfectly.

RewriteCond %{HTTP_HOST} ^(exampledomain.ca)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(exampledomain.basedomain.ca)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www.exampledomain.basedomain.ca)$ [NC]
RewriteRule ^(.*)$ http://www.exampledomain.ca/$1 [R=301,L]

I registered exampledomain.com, exampledomain.net and exampledomain.org and included them as addon domains with the same document root as exampledomain.ca.

I then edited htaccess to include the following:

RewriteCond %{HTTP_HOST} ^(exampledomain.com)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www.exampledomain.com)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(exampledomain.org)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www.exampledomain.org)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(exampledomain.net)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www.exampledomain.net)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(exampledomain.ca)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(exampledomain.basedomain.ca)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www.exampledomain.basedomain.ca)$ [NC]
RewriteRule ^(.*)$ http://www.exampledomain.ca/$1 [R=301,L]

The problem is that if I use www.exampledomain.com or www.exampledomain.org I get nothing. If I leave off the www they redirect fine; and exampledomain.net redirects properly with or without the www.

Any ideas?
Obsolescence is just a lack of imagination.

Sign up at ASO and enjoy friendly, quality hosting services. Use coupon code no2512 and save 15% or coupon code 2152on and take $5 off. Valid on both Shared Hosting and VPS plans.

#2 v0id

v0id

    OMG! I Think I Broke It!!!

  • Members
  • PipPipPipPipPipPip
  • 1,083 posts

Posted 07 March 2012 - 08:45 AM

Do all  the addon domains have a cname for www?

Edited by v0id, 07 March 2012 - 08:45 AM.

IPB Image

#3 NyteOwl

NyteOwl

    36 Bits forever!

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 1,902 posts

Posted 07 March 2012 - 12:33 PM

Yes. I ound the problem. I should have posted but it was late. For some reason my router decided to use ns5.asmallorange.com.localdomain.tld to resolve the www for .com and .org. No Idea why but a small router change fixed the problem.
Obsolescence is just a lack of imagination.

Sign up at ASO and enjoy friendly, quality hosting services. Use coupon code no2512 and save 15% or coupon code 2152on and take $5 off. Valid on both Shared Hosting and VPS plans.

#4 IBBoard

IBBoard

    Massive Orange

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 4,729 posts

Posted 09 March 2012 - 02:39 PM

Assuming you're trying to force a single pattern for all domains that are using that one folder, would it not be easier to do this?
RewriteCond %{HTTP_HOST} !=www.exampledomain.ca [NC]
RewriteRule ^(.*)$ http://www.exampledomain.ca/$1
That's from memory, but it should be using the mod_rewrite short-hand to say "if HTTP_HOST is now www.exampledomain.ca then redirect to www.exampledomain.ca". The fact that it is a .htaccess in a folder should mean that it'll only be triggered on the list of domains you point to that folder (with and without www.) as well as any future domains you add, but with no changes necessary.
The more information you provide, the better answer the community can give.

*** Sign up at ASO  with a 15% discount (coupon: saveme15%) or $5 discount (coupon: saveme$5) ***
(Valid on shared hosting and VPS)

#5 NyteOwl

NyteOwl

    36 Bits forever!

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 1,902 posts

Posted 10 March 2012 - 12:45 PM

Yep that works too, and as you noted is far easier. However, I had originally planned on some subdomains which would never be reached using the shortened option so I did it the long way from the start :)
Obsolescence is just a lack of imagination.

Sign up at ASO and enjoy friendly, quality hosting services. Use coupon code no2512 and save 15% or coupon code 2152on and take $5 off. Valid on both Shared Hosting and VPS plans.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users