URL Rewrite module pointing to blog.mycompany.com

Discussion in 'DNS/Domain names' started by frekster, Mar 13, 2011.

  1. All,

    I know there is tons of information on the forums about using the URL Rewrite module in iis 7 manager. However, I cannot get the syntax correct. Can someone, anyone, please post the URL syntax to copy/paste into my web.config file for the following URL?

    the bad URL pointing to the /blog sub folder is:

    http://www.mycompany.com/blog/index.php/2011/03/09/hellow-venus/

    the good URL should not include the /blog in the URL and be rewritten as:

    http://blog.mycompany.com/index.php/2011/03/09/hellow-venus/

    Note: the /blog/ folder is not in the good url because blog.mycompany.com should point to the /blog sub-folder so I do not want to show it in the URL.

    Can some kind person please post me the syntax for the url rewrite rule? I am pulling out my hair over here and just cannot get it to work.

    thanks to any person who can help me!

    /Justin
     
  2. Ray

    Ray

    Try using these instructions to setup the URL Rewrite module within IIS 7 Manager.

    If you need additional instructions to connect to our web server using IIS 7 Manager then look at this kb article.

    http://support.Winhost.com/KB/a628/using-the-microsoft-iis-70-manager.aspx


    1. Log into the server using IIS 7 Manager. If you are unsure on how to setup your IIS 7 Manager to connect to a Winhost server, refer to this kb article. http://support.Winhost.com/KB/a628/using-the-microsoft-iis-70-manager.aspx
    2. Once you are logged in go to module labeled “URL Rewrite”.
    3. Click on ‘Add Rules…’, and choose ‘Blank rule’ from the Add rule(s) window
    4. Type a name for the rule, I used ‘Rule1’.
    5. Make sure you choose ‘Matches the pattern’ in the Requested URL: drop down box and ‘Regular Expression’ in the Using: drop down box.
    6. the Pattern text box type (.*)
    7. Click on the button ‘Add Conditions’ then under the drop down box labeled ‘Logical Grouping:’ choose ‘Match Any’ and click on the ‘Add’ button.
    8. Type {HTTP_HOST} for Condition input.
    9. Type ^mydomain\.com$ in the ‘Pattern:’ text box. Note the carrot sign ‘^’, the forward slash ‘\’, and the dollar sign ‘$’, these are regular expression symbols that you will need to add. Type the pattern just as I lay out.
    10. The rule will only look for calls that is ‘http://mydomain.com’ and it will not filter calls of other domains such as ‘http://www.domainpointer.com’. To have the rule also encompass ‘http://www.domainpointer.com’, you will need to click on the Add button again and create the condition. You will run through steps 8 thru 9 but in the Pattern text box you will type ^www.domainpointer\.com$
    11. When the conditions are defined, you will be back in the Edit Rule window; choose ‘Redirect' in the ‘Action Type:’ drop down box.
    12. In the ‘Redirect type:’ text box type http://www.mydomain.com/{R:1}
    13. Put a check mark next to ‘Append query string’.
    14. To make sure that you do not get a negative impact on the search engines, you should choose "Permanent (301)" on the Redirect URL text box
     
    Last edited by a moderator: Oct 14, 2015
  3. Ray,

    thanks! I added the rule but need to slightly adjust it. I may have not explained my condition properly and I am sorry about that. Please bare with me.

    When a user types in this address:

    http://blog.mycompany.com

    I have a sub domain created to blog.mycompany.com in the control panel. So when a person types that address in the URL I need to redirect them to a /blog folder in the root of my website. So it would redirect to /blog but not show /blog in the URL. For example:

    http://blog.mycompany.com

    actually points to /blog in the root of my website.

    but the url in the address bar would only show:

    http://blog.mycompany.com

    and not show:

    http://blog.mycompany.com/blog/

    Does that make sense?

    Can you please help me adjust the syntax for the rule?

    thank you for your patients!

    /Justin
     
  4. Ray

    Ray

    The instructions I placed at the thread should work for what you are looking to do, but instead for the redirect type type /blog/{R:1}.
     
  5. I figured it out! Hurray! :)

    Follow all of Ray's initial steps up to step 7 then follow these if you want to have blog.mycompany.com point to a /blog folder in the root of your website:

    8. Type {HTTP_HOST} for Condition input.
    9. Type ^blog.mydomain\.com$ in the ‘Pattern:’ text box. Note the carrot sign ‘^’, the forward slash ‘\’, and the dollar sign ‘$’, these are regular expression
    10 - skipped this step
    11. When the conditions are defined, you will be back in the Edit Rule window; choose ‘Rewrite' in the ‘Action Type:’ drop down box.
    12. In the ‘Rewrite:’ text box type \blog\{R:0}
    13. Put a check mark next to ‘Append query string’.
    14. To make sure that you do not get a negative impact on the search engines, you should choose "Permanent (301)" on the Redirect URL text box
    15. click apply

    hope that helps someone else!
    /Justin
     
  6. Thanks for that follow-up.
     

Share This Page