Redirecting root url to home page

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 23 Aug 2012, 14:50

Redirecting root url to home page

23 Aug 2012, 14:55

I'm hacking my way through this, and would greatly appreciate your feedback.

In order to prevent duplicate content issues I would like to permanently redirect my root domain to the default page in the site

i.e http://www.site.com & site.com ---> to http://www.site.com/defualt.aspx

I already have an .htaccess file setup with the following code, which address another issue I faced a while back.

RewriteEngine On
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)?
RewriteRule ^(.*)(eurl.axd/.*)$ http(?%1s)://www\.%2/$1 [R=301,L]

What should be added to the file? :D

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting root url to home page

23 Aug 2012, 16:21

Hello,

There's one that redirects non-www to www version:
Code: Select all
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]


and there's one to redirect to default.aspx

Code: Select all
RewriteRule ^$ /default.aspx [NC,R=301,L]


Regards
Andrew

User avatar
Posts: 24
Joined: 27 Nov 2012, 21:57

Re: Redirecting root url to home page

02 Dec 2012, 21:45

This is only for version 3.0, right? Thanks.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting root url to home page

02 Dec 2012, 22:11

It also works in Ape.

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: Redirecting root url to home page

06 Dec 2012, 12:50

HeliconAndrew wrote:Hello,

There's one that redirects non-www to www version:
Code: Select all
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]


and there's one to redirect to default.aspx

Code: Select all
RewriteRule ^$ /default.aspx [NC,R=301,L]


Regards
Andrew


Is this more efficient than the IIS default-document process?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting root url to home page

06 Dec 2012, 13:55

It is a substitution, I wouldn't say it's more or less efficient.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 48 guests