Rule Priority Process
4 posts
• Page 1 of 1
Rule Priority Process
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
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
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rule Priority Process
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
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
- tidaltides
- Posts: 24
- Joined: 27 Nov 2012, 21:57
Re: Rule Priority Process
I agree. It totally worked on me as well.
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests