"encounter" with forcing preferred hostname

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
5/19/2011 10:44:14 AM
Gravatar
Total Posts 73

"encounter" with forcing preferred hostname

I've been a user of the "allow forcing preferred host name" setting for some time now, but I've always been a bit leery of it, and I finally got bit.  It took me some time and research to fix it once it was broken, and since my site was down for the duration, I figure I should recount it here in the hope that it helps someone.

The preferred host name setting is documented here:

http://www.mojoportal.com/forcing-a-preferred-host-name.aspx

The idea is that since a user may visit your site through multiple names ("site.com" as well as "www.site.com"), this isn't great for search optimization since the same page may have two search entries, diluting it.  I don't know if this is also fixed by canonical urls, but I'm not that savvy and it sounds like a good idea to force the full name anyway since I run multiple sites on my installation.

You can use either this setting or URL rewriting to redirect users to the full preferred name of your site.  Since I don't have URL rewriting on, I chose this setting.

The problem is, if you get the setting wrong, you take your site down since it always redirects to a wrong name.  Since the setting is done through the admin interface on the site itself, you've basically screwed yourself and have to find the setting in the database directly, or turn it off in web.config.

I won't go too in-depth on how I ended up setting it wrong.  I'm not just an idiot. ;)  Basically I was setting up a virtual machine clone of the site and trying to adjust the setting for the clone, and the redirect kicked me to my main site.  I failed to notice that and set the main sites preferred host name to be that of the clone.

Thinking about it, that's naturally a problem with any clone, it's always going to kick you to the main site automatically.  So you have to turn the feature off in the web.config of the clone before doing *anything* to the clone.

So my main site went down.  Took me a few minutes for the report to come in, because it looked ok to me (it was redirecting to the internally available clone).  Once I figured out what was going on, I turned off the feature in web.config and the site came back up.

But I wanted the feature on for my main site.  Unfortunately, when you turn it off, the configuration field in the site settings goes away, so now I couldn't put it back to its former value.  It would be nice if the configuration field were still there, with perhaps a checkbox to turn the feature off and on.

As it stood, I couldn't reset it from the user interface, so I had to track down the field in the database, as the documentation page mentions.  Unfortunately, the documentation doesn't mention where that field is.

I could've asked on the forum, but since I already have the source, I did a few searches before I figured out that it's in the dbo.mp_sites table as apikeyextra5.  Reset it to the desired value and restart the site and voila.

Hopefully this saves someone else a few desperate minutes.

5/19/2011 10:55:51 AM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: "encounter" with forcing preferred hostname

Thanks for posting your experience, Thomas. I've had a similar experience, though not as destructive to the live site fortunately. I've since made sure that the AllowForcingPreferredHostName key is in the user.config of every development copy as well as the live site, and make sure it's turned off everywhere but production.

I'll update the documentation to explicitly mention the field that needs to be updated in the database for this situation.

Jamie

5/19/2011 11:01:16 AM
Gravatar
Total Posts 18439

Re: "encounter" with forcing preferred hostname

Next time I'm adding fields to the mp_Sites table I'll add a new one with a more obvious name and migrate from that apkiextrakey5 field, it was used as a convenience because it already existed and wasn't used for anything else. 

Go ahead and update the document though Jamie, whenever I do change it to a new field I'll update the doc. I'll make a note in the project tracker about it.

Best,

Joe

5/19/2011 2:12:01 PM
Gravatar
Total Posts 73

Re: "encounter" with forcing preferred hostname

You da men, guys.

You must sign in to post in the forums. This thread is closed to new posts.