Rewrite to domain based on subdirectory

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 6
Joined: 12 Sep 2012, 12:40

Rewrite to domain based on subdirectory

12 Sep 2012, 12:53

Hi,

I'm a noob with ISAPI_Rewrite so please be gentle :)

www.fristdomain.com is the main domain and has a folder called seconddomain (http://www.fristdomain.com/seconddomain)

I'm looking for a way to do the following:

1. When a visitor goes to www.fristdomain.com/seconddomain redirect him/her to www.seconddomain.com
2. When a visitor goes to www.seconddomain.com, show the contents of www.fristdomain.com/seconddomain but leave the URL of www.seconddomain.com. For example www.fristdomain.com/seconddomain/test/something.html would be www.seconddomain.com/test/something.html in the browser.

Hope someone can help me out here :(
Many thanks in advance.

Regards,
Frank

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

Re: Rewrite to domain based on subdirectory

12 Sep 2012, 23:57

Hello Frank,

thanks for a clear description of what you need. As you have two tasks, there will be two rules for httpd.conf:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} ^www\.fristdomain\.com$ [NC]
RewriteRule ^seconddomain(/.*)$ http://www.seconddomain.com$1 [NC,R=301,L]

RewriteCond %{HTTP:Host} ^www\.seconddomain\.com$ [NC]
RewriteRule (.*) http://www.fristdomain.com/$1 [NC,P,L]


Regards
Andrew

User avatar
Posts: 16
Joined: 13 Nov 2012, 00:19

Re: Rewrite to domain based on subdirectory

16 Nov 2012, 22:57

I find this helpful since I have tried it and it worked.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 7 guests