Redirection from maindomain.subdomain to www.subdomain.com?

Joomla version 1.5 is end-of-life and are no longer supported. Please use Joomla 3.x instead.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
WGH
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun May 11, 2014 3:20 pm

Redirection from maindomain.subdomain to www.subdomain.com?

Post by WGH » Sun May 11, 2014 3:53 pm

I have two separate websites, not related. one is in the public_html folder and works fine at www.maindomain.com. I have added a new website in a subfolder of the public_html folder.

I am using cpanel.

Presently I can find my second website by typing www.maindomain.subdomain.com. This is not ideal. I need the second new web site URL to be www.subdomain.com.

How do i do this? I see from forum discussions that I will need to modify the htaccess files in both the public_html folder and subfolder. All the posts cover redirecting the subdomain url. I need to hide/remove the maindomain part of the URL.

 
User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by dhuelsmann » Sun May 11, 2014 4:08 pm

Add the following to your .htaccess in your maindomain after the rewrite engine is turned on.

Code: Select all

RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.maindomain\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^!www\.subdomain\.com [NC]
RewriteRule ^(.*)$ http://www.subdomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^subdomain.com [NC]
RewriteRule ^(.*)$ http://www.subdomain.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/subdomain($|/.*$)
RewriteRule ^.* http://www.subdomain.com%1 [R=301,L]
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

WGH
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun May 11, 2014 3:20 pm

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by WGH » Sun May 11, 2014 6:42 pm

Hi Dave. Thanks for the time and effort.

I entered this into a blank .htaccess file in my root public_html folder.
Where: hedgehoglane.co.za is in the root public_html folder and johngiclarke.co.za is in the subfolder off the public_html folder.

# mod_rewrite in use

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?johngiclarke\.co\.za\.hedgehoglane\.co\.za [NC,OR]
RewriteCond %{HTTP_HOST} ^!www\.johngiclarke\.co\.za [NC]
RewriteRule ^(.*)$ http://www.johngiclarke.co.za/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^johngiclarke.co.za [NC]
RewriteRule ^(.*)$ http://www.johngiclarke.co.za/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/johngiclarke($|/.*$)
RewriteRule ^.* http://www.johngiclarke.co.za%1 [R=301,L]

if i now enter the following into my url bar www.johngiclarke.co.za i get the typical "Server not found" message.

What do i need to do to get this working? Have I made an error above?

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by dhuelsmann » Sun May 11, 2014 6:56 pm

Did you create an add-on domain in your cpanel? Did you register your new domain and have it point to your host's DNS servers?
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

WGH
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun May 11, 2014 3:20 pm

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by WGH » Sun May 11, 2014 7:03 pm

Hi Dave

Yes to all.

if I enter www.hedgehoglane.co.za/johngiclarke.co.za I get a web page. I just want to get rid of the hedgehoglane.co.za part of the url.

IOW. i just want to enter www.johngiclarke.co.za and go directly to the correct web page

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by dhuelsmann » Sun May 11, 2014 7:19 pm

Try this with the minor change of removing the slashes between .co and .za

Code: Select all

# mod_rewrite in use

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?johngiclarke\.co.za\.hedgehoglane\.co.za [NC,OR]
RewriteCond %{HTTP_HOST} ^!www\.johngiclarke\.co.za [NC]
RewriteRule ^(.*)$ http://www.johngiclarke.co.za/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^johngiclarke.co.za [NC]
RewriteRule ^(.*)$ http://www.johngiclarke.co.za/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/johngiclarke($|/.*$)
RewriteRule ^.* http://www.johngiclarke.co.za%1 [R=301,L]
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

WGH
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun May 11, 2014 3:20 pm

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by WGH » Sun May 11, 2014 7:30 pm

Hi Dave

Nope. No change. Still get "server error"

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by dhuelsmann » Sun May 11, 2014 8:07 pm

One more try then I am out of ideas if it doesn't work.

Code: Select all

RewriteEngine on
RewriteCond %{HTTP_HOST} ^ hedgehoglane.co.za$ [OR]
RewriteCond %{HTTP_HOST} ^ www.hedgehoglane.co.za$
RewriteRule ^ johngiclarke.co.za/?(.*)$ "http\:\/\/www\.hedgehoglane\.co\.za\/$1" [R=301,L]
RewriteCond %{HTTP_HOST} ^ johngiclarke.co.za.hedgehoglane.co.za$ [OR]
RewriteCond %{HTTP_HOST} ^ www.johngiclarke.co.za.hedgehoglane.co.za$
RewriteRule ^/?(.*)$ "http\:\/\/www\.hedgehoglane.co.za\.co\.za\/$1" [R=301,L]
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by dhuelsmann » Sun May 11, 2014 8:11 pm

If the above doesn't work try your CPanel url redirect. It might do it better than me, who knows?
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

WGH
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun May 11, 2014 3:20 pm

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by WGH » Sun May 11, 2014 8:20 pm

Hi Dave - thanks for all the effort!
The last code crashed the main website.

I did try the cpanel redirect panel without any joy prior to posting.

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Redirection from maindomain.subdomain to www.subdomain.c

Post by dhuelsmann » Sun May 11, 2014 8:34 pm

Well darn!
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

 

Locked

Return to “Migrating and Upgrading to Joomla! 1.5”