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

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

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

| improve this answer | |
  • 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 Mar 12 '18 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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