Rule Priority Process

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Rule Priority Process

19 Oct 2012, 14:49

Hi,

I have a website with the domain: website.com and I just acquired another website with the domain newstuff.com. I created a mapfile to redirect the newstuff.com pages to the website.com pages and this works great. Now I want to create a redirect for when people only type newstuff.com so that it redirects to website.com/thispage.html. Here is what I tried:

#Rule 1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
Rewriterule ^index\.asp$ /${mapfile:%1}? [NC,R=301,L]

#Rule 2
RewriteCond %{HTTP_HOST} www.newstuff.com [NC]
RewriteRule (.*) http\://www.website.com/thispage.html?redir=yes [R=301,L]

The problem now is that with Rule 2 in the mix, Rule 1 never executes and is useless.

How can I make it so that Rule #1 will execute first and if it does not apply then execute Rule #2?

Much Appreciated,

John

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

Re: Rule Priority Process

22 Oct 2012, 00:29

The order is correct and logic is clear.

It's just that your second rule states that ANY request to newstuff.con will redirect to website.com/thispage.html?redir=yes. So the first rule is exdecuted, it's just that you don't see the result, as it is overlapped with the second rule. If you want to redirect just the root of the newstuff.com, try replacing (.*) with ^$.

Regards
Andrew

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Rule Priority Process

22 Oct 2012, 14:27

Thank You Andrew!

That worked, it was exactly what I needed it to do.

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

Re: Rule Priority Process

01 Dec 2012, 00:53

I agree. It totally worked on me as well.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 6 guests