Domain redirection for WDL

Several people have registered WDL for a domain but they have more than one prefix. For example you might be able to get to the site by going to http://www.mysite.com or via http://mysite.com. The serial number is only valid for one of these sites so users can potentially get a serial number error. You can get around this by using this small javascript which will automatically redirect visitors to your site with the domain with the serial number.

To use enter this script into the html page between the tags -

Make sure you enter your web paths into the variables above. Now anyone coming to your page via http://www.mysite.com/weather/index.html will automatically be redirected to http://mysite.com/weather/index.html and avoid the serial number error.

Julian

You can do this with the web server if you are using Apache with mod_rewrite enabled.

In the .htaccess file in the top directory of the website…

RewriteCond %{HTTP_HOST}   !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.mysite.com/$1 [L,R]

This will take in input of just plain http://mysite.com and turn it into http://www.mysite.com before handing it off to the web page.

You might need to add at the top

RewriteEngine on

This would work even if the user had javascript turned off.

Yes there are lots of ways of doing this. For example if you have asp capability (running a Windows IIS box) then you can put this at the top of your asp page -

<%

Dim strWrongDomain, strCorrectDomain

strWrongDomain = “www.mysite.com
strCorrectDomain = “mysite.com

If Request.ServerVariables(“http_host”) = strWrongDomain Then
Response.Redirect “http://” & strCorrectDomain & Request.ServerVariables(“URL”)
End If

%>

Julian

Hi Julian,

Now I can forget one problem in my site.

Many thanks! :smiley:

Cheers
Eki

Hi Julian,

Now I can forget one problem in my site.

Many thanks! :smiley:

Cheers
Eki

Me too.
Sometimes a browser will insert a www. in front of the web address if the web address does not begin with a www.
These fixes are good. Thank you. :smiley: