Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Jul 27, 2011 4:52 pm 
Offline
Senior Newbie

Joined: Wed Feb 09, 2011 7:44 pm
Posts: 9
Website: http://emken.biz
hello, I've done some searching but haven't found anything that really answers my question.

I have the domains, let's say: mydomain.com, mydomain.net, mydomain.co etc. mydomain.com is my main website. What would be the best way to redirect the .net and .co domains to mydomain.com with as little interference as possible and without the user being interrupted. I do not want, for example, mydomain.net to serve the same content as mydomain.com but still show the .net domain in the URL bar, but I want it to actually redirect to the .com

I am running LAMP on debian.

Thanks


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 6:40 pm 
Offline
Senior Newbie

Joined: Tue Aug 02, 2011 6:12 pm
Posts: 11
What I've done with my domains is have a vhost setup for my main domain pointing at one directory, and the others "children" domains point at another directory, which has an index.php file that just 301 redirects to the main site. Might not be the nicest way to do it but I've read it doesnt hurt your SEO stats like other methods.

Code:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>


Good luck


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 6:50 pm 
Offline
Senior Member

Joined: Sun Apr 26, 2009 3:37 am
Posts: 72
Website: http://wiggenhorn.org/
Enable mod_rewrite and have something like this in your vhost configuration file (in /etc/apache2/sites-available):

Code:
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAlias mydomain.net
ServerAlias www.mydomain.net


RewriteEngine on
RewriteCond %{HTTP_HOST} !^mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://mydomain.com/$1 [L,R=301]


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 8:25 pm 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
Another method is to simply use Apache's RedirectMatch:

Code:
<VirtualHost *:80>
ServerName mydomain.net
ServerAlias mydomain.co
RedirectMatch permanent ^(.*)$ http://mydomain.com$1
</VirtualHost>

<VirtualHost *:80>
ServerName mydomain.com
# Complete configuration here...
</VirtualHost>



Would redirect all requests for mydomain.net and mydomain.co to mydomain.com

_________________
sleddog


Top
   
 Post subject:
PostPosted: Wed Aug 03, 2011 8:59 am 
Offline
Senior Newbie

Joined: Tue Aug 02, 2011 6:12 pm
Posts: 11
sleddog wrote:
Another method is to simply use Apache's RedirectMatch:

Code:
<VirtualHost *:80>
ServerName mydomain.net
ServerAlias mydomain.co
RedirectMatch permanent ^(.*)$ http://mydomain.com$1
</VirtualHost>

<VirtualHost *:80>
ServerName mydomain.com
# Complete configuration here...
</VirtualHost>



Would redirect all requests for mydomain.net and mydomain.co to mydomain.com



Thanks, I like that approach much better as I dont even need to have a separate directory structure for my extra domains, and my vhost file is much cleaner.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group