Redirect to different "homepage" using localization
Hi, I'm new to Umbraco, I recently did some test and understand how to work with DocumentType and Macro. I also understand how to work with usercontrol and c#. Now what I want to do is on the home page, look in a db using visitor's ip to see where is from and redirect to a specific page depending on my result. Can you provide me an exemple on how I could do that please? I just don't know what would be the best way of executing this code first and redirect to one of the 3 homepages.
Thanks a lot!
PS : I think Umbraco rules, I worked with lots of CMS and none was killing it like this one! (hope to see it on MVC soon!)
Here's something I've used to redirect visitors based on IP. This was to redirect internal network traffic to a different page
On the homepage I had two properties: internalIPAddresses for a list of IPs to check against, and "internalHomepage", which was a contentpicker with the page to redirect to. I also hard-coded a regex for an ip range - I got the regex from the tool at http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55572
Here's the xslt - post back if you want me to go through it in more detail (it's 5:30pm here and i'm leaving!).
<msxsl:script language="VB" implements-prefix="vb"> <msxsl:assembly name="System.Web"/> <![CDATA[ Public Function Redirect(url As String) System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently" System.Web.HttpContext.Current.Response.AddHeader("Location", url.ToString) Return "" End Function ]]> </msxsl:script>
Is ther a way of doing this only in C#/VB since you say it yourself that having script inside XSLT is not a best practice? And how do I do to make the code execute on the load of the first page?
Redirect to different "homepage" using localization
Hi, I'm new to Umbraco, I recently did some test and understand how to work with DocumentType and Macro. I also understand how to work with usercontrol and c#. Now what I want to do is on the home page, look in a db using visitor's ip to see where is from and redirect to a specific page depending on my result. Can you provide me an exemple on how I could do that please? I just don't know what would be the best way of executing this code first and redirect to one of the 3 homepages.
Thanks a lot!
PS : I think Umbraco rules, I worked with lots of CMS and none was killing it like this one! (hope to see it on MVC soon!)
Hi Vincent, and welcome to the forums!
Here's something I've used to redirect visitors based on IP. This was to redirect internal network traffic to a different page
On the homepage I had two properties: internalIPAddresses for a list of IPs to check against, and "internalHomepage", which was a contentpicker with the page to redirect to. I also hard-coded a regex for an ip range - I got the regex from the tool at http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55572
Here's the xslt - post back if you want me to go through it in more detail (it's 5:30pm here and i'm leaving!).
p.s. script inside xslt is not best practice!
Dan
Thanks Dandrayne for the reply!
Is ther a way of doing this only in C#/VB since you say it yourself that having script inside XSLT is not a best practice? And how do I do to make the code execute on the load of the first page?
Thaks again!
Hi Vincent
It's best (iirc - i'm front-end!) to create an xslt extension, but using something like the above won't be a major problem.
As for making it run on page load; if you use the above in a macro and place it anywhere on your masterpage/template it will run on page load.
Dan
Thanks Dan, I'll try this later in my project and I'll let you know if I have questions but it seems pretty clear!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.