ISAPI_rewrite multy string search and rewrite to one

61 Views Asked by At

I'm new to this, need help writing this rewrite code. I have 7 domains parked on same server and each domain content is in it's own folder currently I'm using like:

RewriteEngine on

RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

RewriteCond %{HTTP:Host} ^(?:www.)?domain1.com$

RewriteCond %{HTTP:Host} ^(?:www.)?domain2.com$

RewriteRule (.*) /folder1-2/$1 [NC,L,NS]

RewriteCond %{HTTP:Host} ^(?:www.)?domain3.com$

RewriteCond %{HTTP:Host} ^(?:www.)?domain4.com$

RewriteRule (.*) /folder3-4/$1 [NC,L,NS]

...and so on -its working, but if some one type like: domain1.com/folder1-2 -url stays same as is, I like to redirect to folder1-2, but url should only say www.domain1.com (with www prefix and without folder1-2).

can someone please help to write using ISAPI_rewrite.

-thanks

1

There are 1 best solutions below

1
On

Try it like this for domain 1 and 2:

RewriteEngine on

RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

RewriteCond %{HTTP:Host} ^(?:www\.)?(domain1|domain2)\.com$
RewriteRule ^folder1-2 http://www.%1.com/ [NC,L,R=301]

RewriteCond %{HTTP:Host} ^www\.(?:domain1|domain2)\.com$
RewriteRule ^/?$ /folder1-2 [NC,L]