ed 
Member 
 
Registered: 10th Sep 03
 
User status: Offline 
 
 | 
 
This is something I really should know, but what's the best way to force one domain name over other alias domain names on a website. I've got three for my portfolio, but I'd like to 301 any requests made by the alias domain names to the main one. 
 
I know I could do this with .htaccess, but for ease, does anyone know of a Wordpress plugin that could perhaps do it? Or, would I even be better off setting up the alias domains as redirects at the DNS level instead?
 | 
Sam 
Moderator Premium Member 
 
Registered: 24th Dec 99
 Location: West Midlands 
User status: Offline 
 
 | 
 
I think on my domains I do this at registrar level (in my case, domainmonster.com). 
 
You can also do this in cPanel IIRC. 
 
[Edited on 18-05-2011 by Sam]
 | 
ENB 
Member 
 
Registered: 24th Apr 06
 
User status: Offline 
 
 | 
 
Wordpress plugin? Guessing you don't have access to the server? 
 
What kind of server is it? Apache, IIS, light-httpd? 
 
Presumably you're trying to say produce a 301 (permanent redirect) from subsite.com to mainsite.com? 
 
I know it's a single line in Apache; which you can add in .htaccess (although it's slower than in the main httpd.conf, but you probably don't have much choice there). 
 
 
Alternatively just set up a CNAME for subsite.com to point to mainsite.com.
 | 
ed 
Member 
 
Registered: 10th Sep 03
 
User status: Offline 
 
 | 
 
It's my server, I've got complete access to it - just wanted a plugin as it would be easier. 
 
The .htaccess stuff seems to mess up my configuration as I'm running WP Super Cache.
 | 
Sam 
Moderator Premium Member 
 
Registered: 24th Dec 99
 Location: West Midlands 
User status: Offline 
 
 | 
 
 
 | 
ed 
Member 
 
Registered: 10th Sep 03
 
User status: Offline 
 
 | 
 
I think the CNAME way would work best actually. 
 
Forgot to say, it's Apache running on Ubuntu with all the usuals.
 | 
Ian 
Site Administrator
 
Registered: 28th Aug 99
 Location: Liverpool 
User status: Offline 
 
 | 
 
I think CNAME will introduce duplicate content on both domains instead of re-writing the address to the preferred site. 
 
I would use a PHP header() call for this, generally the most simple to set up.
 | 
ed 
Member 
 
Registered: 10th Sep 03
 
User status: Offline 
 
 | 
 
On Ian's advice, I've found a Wordpress plugin that forces www at the beginning of your URL's. I'll modify that to force my preferred domain name via a 301. 
 
It's a pain you have to go down the custom plugin route, but I haven't found anything that'll do this for Wordpress - maybe I should make it good and publish it  
 | 
Sam 
Moderator Premium Member 
 
Registered: 24th Dec 99
 Location: West Midlands 
User status: Offline 
 
 | 
 
I've made about three WordPress plugins purely because there wasn't anything better suited to my requirements at the time, and I decided to release them on wordpress.org. 
 
One of them has had over 12k downloads!   
 
[/shouldhavechargedmoneyforthem]
 | 
ed 
Member 
 
Registered: 10th Sep 03
 
User status: Offline 
 
 | 
 
You seem to be able to stick donate buttons and adverts into the backend if you were really desperate!  
 | 
Ian 
Site Administrator
 
Registered: 28th Aug 99
 Location: Liverpool 
User status: Offline 
 
 | 
 
If I've got this right and you have three domains and they each point to different folders in the hosting, have your Wordpress install in one folder and in the others, make a file named index.php and put in: 
 
<?php 
header('Location: http://www.yourothersite.com/'); 
?> 
 
You don't need plugin for that?
 | 
ENB 
Member 
 
Registered: 24th Apr 06
 
User status: Offline 
 
 | 
 
How does a CNAME duplicate content?
 |