Helicon Ape - mod_rewrite question

Posted on 2011-10-11
Last Modified: 2012-05-12
Hi guys

On a server, Win2008 R2, I installed Helicon Ape in IIS.

Now on a specific site, I'd like to redirect (301 Permanent) any visitors that arrives at the site using the domain-name without www. or anything else before the domain.

So if the visitor visits do nothing
If the visitor visits do nothing
BUT if the visitor visits - redirect 301 to

Any one who can help me out here ??
Question by:trg_dk
    LVL 30

    Accepted Solution


    If APE is setup properly and mod_rewrite is enabled, then a simple .htacess rule will suffice. You can add this to your Root folders (.htaccess) file.

    RewriteEngine on
    RewriteBase /
    rewritecond %{http_host} ^ [NC]
    rewriterule ^(.*)$$1 [NC,R=301]

    Now, if mod_rewrite is all you need and your are just trialing APE, you can install the free module, IIS URL Rewrite to do the same thing.

    IIS URL Rewrite

    You can also use Microsoft's IIS URL Rewrite module as well. For example, a very simple redirect rule will take care of that as well.

    In your Websites root web.config

    <rule name="Canonical Host Name" stopProcessing="true">
      <match url="(.*)" />
        <add input="{HTTP_HOST}" negate="true" pattern="^domain\.com$" />
      <action type="Redirect" url="{R:1}" redirectType="Permanent" />

    Hope it helps. Let us know if you have any other issues.
    LVL 2

    Author Comment

    Hi :)

    I bought APE and it works for other functions, så this should be just plud and play I guess!!

    Thanks for your time, will test it tonight!
    LVL 2

    Author Comment

    hades666 - sorry for the (long) delay :(

    How can I make it universal, så for any site in IIS7 - if the user acesses the site without any pre-domain url (www/shop/cms/etc) they always gets redirected to the current site, using www.

    The code works fine but requires me to do this for 300 sites - not an option :/

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
    Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now