3

For all kind of vanity URL redirection we are using URL Rewrite module in our sitecore project which is running fine. For Ex:

CASE 1

Input URL: www.mysite.com/history

Target URL: www.mysite.com/page1/page2/history --> This is handled by URL Rewrite module

Now we have to handle sub-domain redirection as given below:

CASE 2

Input URL: location.mysite.com

Target URL: www.mysite.com/locations

Input URL: customerfeedback.mysite.com

Target URL: www.mysite.com/company/department/sales/feedback

How should handle these scenario because sub-domain URLs( location.mysite.com ) are pointing to some other servers which are actually serving the pages right now

As a starting point first of all we have to change DNS mapping of given sub-domain URL so that those can start pointing to www.mysite.com Load balancer IP address

What would be the next step. Assuming we might need to write down some custom code for this

UPDATE: See below Input/Target URL configured in Sitecore and redirection using sitecore URL rewrite module feature

enter image description here

UPDATE 3/25/2018

DNS level changes has been completed. I can see see location.mysite.com is pointing to same IP as mysite.com.

URL Rewrite changes has been published from CM instance. see below all settings

enter image description here

location.mysite.com binding has been added in IIS. While browsing location.mysite.com getting below error. Might be I'm missing something.

enter image description here

2
  • I think I should have mentioned about module so here I'm talking about sitecore rewrite module which is available on marketplace marketplace.sitecore.net/Modules/Url_Rewrite.aspx If so where should we post Sitecore module specific question
    – Sukhjeevan
    Commented Mar 12, 2018 at 5:40
  • 1
    I retracted my vote Commented Mar 12, 2018 at 6:00

2 Answers 2

3

The Sitecore URL rewrite module is conceptually based on the IIS Rewrite Module Shiva referenced.

You would essentially do the same thing Shiva outlined but withing Sitecore using the Inbound Rule with a Condition instead of the Simple Redirect way you are trying now.

Steps:

  1. Create a new Inbound Rule item - call it whatever you want
    • Pattern: (.*)
  2. Create a new Condition Item under the item above called HTTP_HOST
    • Condition Input Ty[e: {HTTP_HOST}
    • Pattern: location.mysite.com
  3. Create a new Redirect Item under item created in step 1
    • Rewrite URL: Either do internal link or external link to where you want to redirect users to

Should look something like this:

enter image description here

7
  • Do I need to add location.mysite.com in IIS Binding
    – Sukhjeevan
    Commented Mar 21, 2018 at 2:43
  • Yes, otherwise your Sitecore site will never resolve to that subdomain. Commented Mar 22, 2018 at 15:22
  • We did that changes but redirection doesn't happened. I have added screen-shot in my post. please check.
    – Sukhjeevan
    Commented Mar 25, 2018 at 17:46
  • OR Should we do any config level changes
    – Sukhjeevan
    Commented Mar 26, 2018 at 19:53
  • Looking at the screenshot, the Pattern field is blank when it should be set to "(.*)". That maybe the issue. Commented Mar 27, 2018 at 23:38
1

After changing DNS of the sub-domain to point to your server IP address, you have to redirect traffic from the sub-domain host name(location.mysite.com) to your target URL(www.mysite.com/locations) in URL redirect module.

Use following redirect rule in URL redirect module

               <rule name="External Site" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="location.mysite.com" />
                </conditions>
                <action type="Redirect" url="www.mysite.com/locations" redirectType="Permanent" />
            </rule>

Condition for URL Redirect

Action for URL Redirect

1
  • As I said we are using sitecore URL Rewrite module to handle vanity URL redirection so we are not using web.config for redirection. Instead we add sitecore item in content tree as shown in image where we add Input URL in Path field and target URL in Target field which is working fine as I mentioned in case 1. I'm looking for a solution to handle sub-domain redirection as per case 2
    – Sukhjeevan
    Commented Mar 12, 2018 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.