This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Rewrite Alias site Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
kati
Newbie
Newbie


Joined: 17 August 2011
Online Status: Offline
Posts: 4
Posted: 17 August 2011 at 7:22am | IP Logged Quote kati

Hi

I've searched the forum but can't find an answer that
works. I have a subdomain of a second site acting as an
alias for my first site. Here is what I'm trying to
achieve:

I want to 301 redirect everything

from: http://sub.mysecondsite.com
to: http://www.myfirstsite.com

except anything with an image extension (jpg, gif
or png)

The result should be:

When I browse, for example:
http://sub.mysecondsite.com/myfolder/ or
http://sub.mysecondsite.com/myfolder/mypage or
http://sub.mysecondsite.com/myfolder/mypage.php

or any other combination of folders, pages and
extensions, the visitor is 301 redirected to
http://www.myfirstsite.com plus the folders and pages
combination.

And when I browse anything on http://sub.mysecondsite.com
with an image extension (jpg, png or gif), there is no
redirect.

Thanks in advance for any help.

Back to Top View kati's Profile Search for other posts by kati
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 17 August 2011 at 8:11am | IP Logged Quote Anton

Please try the following:

[ISAPI_Rewrite]

RewriteCond Host: sub\.mysecondsite\.com
RewriteRule (?!.*\.(?:jpg|gif|png))(.*) http://www.myfirstsite.com$1 [I,RP]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
kati
Newbie
Newbie


Joined: 17 August 2011
Online Status: Offline
Posts: 4
Posted: 17 August 2011 at 9:37am | IP Logged Quote kati

Many thanks for the reply.

- This works perfectly for not redirecting images. It
also works perfectly for redirecting pages on
www.myfirstsite.com which have not already been
rewritten.

But it doesn't redirect pages on www.myfirstsite.com that
have already been rewritten.

A couple of examples:

1. www.myfirstsite.com/page has been rewritten from
www.myfirstsite.com/page.asp.

When I navigate to sub.mysecondsite.com/page, there is no
redirect. When I navigate to
sub.mysecondsite.com/page.asp, it redirects to
www.myfirstsite.com/page.

2. www.myfirstsite.com/folder/page.asp?parameter=name has
been rewritten to www.myfirstsite.com/folder/name/. When I navigate to sub.mysecondsite.com/folder/name/, there is
no redirect. When I navigate to
sub.mysecondsite.com/folder/page.asp?parameter=name, it
redirects to www.myfirstsite.com/folder/name/.

Is there a way to include in the rule to take into
account these pages that have already been redirected in
www.myfirstsite.com ?

Thanks a lot!

Back to Top View kati's Profile Search for other posts by kati
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 18 August 2011 at 2:29am | IP Logged Quote Anton

So, this means you already have some rules in your ISAPI_Rewrite config.
Could you please show the whole config you have at the moment.

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
kati
Newbie
Newbie


Joined: 17 August 2011
Online Status: Offline
Posts: 4
Posted: 18 August 2011 at 3:33am | IP Logged Quote kati

Hi Anton

I had the rule in the httpd.ini file of
www.myfirstsite.com. It works here because
http://www.myfirstsite.com is canonical of
http://sub.mysecondsite.com
- putting it in httpd.ini at http://mysecondsite.com or
http://sub.mysecondsite.com however didn't work.

As such, I have about 200 custom rules in the httpd.ini
of www.myfirstsite.com for host www.myfirstsite.com. The
problem was that I put your rule at the bottom of this
file, after al these custom rules. Just moving it to the
top, above all the custom rules for www.myfirstsite.com,
worked!

Do you see any problem with doing it this way?

Thanks for all your help.
Back to Top View kati's Profile Search for other posts by kati
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 18 August 2011 at 8:19am | IP Logged Quote Anton

"Do you see any problem with doing it this way?"
- there's no problem in having it this way.
The problem may have occurred because of some incorrect or imprecise rules which interfered with the newly added ones..

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
kati
Newbie
Newbie


Joined: 17 August 2011
Online Status: Offline
Posts: 4
Posted: 25 August 2011 at 2:30pm | IP Logged Quote kati

Many thanks Anton. It all works well now.
Back to Top View kati's Profile Search for other posts by kati
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum