• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 839
  • Last Modified:

Helicon Ape - mod_rewrite question

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 shop.domain.com do nothing
If the visitor visits www.domain.com do nothing
BUT if the visitor visits doamin.com - redirect 301 to www.domain.com

Any one who can help me out here ??
0
trg_dk
Asked:
trg_dk
  • 2
1 Solution
 
Brad HoweCommented:
Hi,

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} ^domain.com [NC]
rewriterule ^(.*)$ http://www.domain.com/$1 [NC,R=301]

http://www.helicontech.com/ape/doc/mod_rewrite.htm

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
http://www.iis.net/download/URLRewrite

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

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

http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/

Hope it helps. Let us know if you have any other issues.
Hades666
0
 
trg_dkAuthor Commented:
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!
0
 
trg_dkAuthor Commented:
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 :/
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now