green field

Forcing a Preferred Host Name

Rate this Content 1 Votes

In some cases you may have a site that will work with more than one host name, but for better tracking in google analytics and for better SEO (search engine optimization), you should force it to use a particular host name no matter which host name the request comes in as. So for example on this site I could use mojoportal.com or www.mojoportal.com or mojoportal.org or mojoportal.net, but for consistent tracking I want to force it to use www.mojoportal.com. Another reason I want to force it to www.mojoportal.com is because my SSL certificate is for www.mojoportal.com and people would get browser warnings about the certificate not matching if they tried to login to mojoportal.com.

To enable forcing a preferred host name, you need to set this as true in your Web.config or user.config file:

<add key="AllowForcingPreferredHostName" value="true" />

Then it will be available in Site Settings:

Preferred Host Name Setting screen shot

In a multi site installation it can only be set from the root admin site, but you can set it there for any site. Be very careful with this setting, the reason its disabled by default is because it will force a redirect to the entered host name and if you put in an incorrect host name you may not be able to access your site without fixing it in the database.

Custom Skinning by Joe Davis Your advertisement here Nominate mojoPortal for the 2010 CMS Awards
Give your site more mojo! Your advertisement here mojoPortal User Group on Yamisee