Rodney
 Posts:64

| | 04/04/2008 5:13 PM |
| Hi John, The new PB module is looking really good - I am just setting up all my 301 redirects and then I am going to try the Static File Handler... So, my question is - I have 30 domains that all point at PokerDIY (missspellings, .co.uks etc.). Google already has indexed loads of them which is bad. 1) Will 30 IF Rules affect performance? 2) When the RegEx expression is found, I assume it stops searching? For example, when I am doing a rule for a 301 redirect, I want it to do it everytime, so I search for some HTML that I know will be on ther page. Should I use HTML that is as high as possible so that it finds it and exits (e.g. the TITLE tag instead of the end HEAD tag) or does this make no difference? 3) Is there any reason why you can't just make a Rule execute on every request instead of doing the fake search like above? Ie. you just check a checkbox saying "Exectute on every Request" instead of searching for "" which you know will always exist? Just curious. I'm going to have lots more questions I'm sure ;) Thanks Rodney Smart-Thinker.com PokerDIY.com | | | |
|
|
|
Rodney
 Posts:64

| | 04/04/2008 9:28 PM |
| | One other thing - I have 30 rules in a row, but as soon as one fires than all the other would be invalid and would not need checking - can you nest IF statements or do a SWITCH type of statement (or possible one big OR statement with 30 domain checks? | | | |
|
John Mitchell Posts:2779


| | 04/05/2008 6:05 AM |
| 30 Rules that check the Url will be hardly noticeable probably taking less than 1/2 a second, but I don't have any real numbers yet.
The fake search part is the easiest way of doing the checkbox like you described. The internal rules processor is very concise and built for performance, so I didn't want to add additional checks on every rule that gets processed. Searching for /title instead of /head may be a little faster, but I bet it is not even measurable. Just make sure you don't search for something that is found multiple times since that would require multiple replaces. As soon as a match is found on the search part it begins doing the replace - respond part of the Rule.
Since you can use regular expressions in your Url matching I'm pretty sure you can get those 30 rules down to just a few with Regex patterns that match most of them. You may even be able to make just one rule if they are all being redirected to the same page.
The IF condition does support AND & OR logical operations, but it does not support nested IF statements. Regular expressions also give you the ability to do "switch like" statements in a single pattern using the OR (com|net|uk). Put the most likely ones towards the first of the list and the rest will be short-circuited.
| | | |
|
Rodney
 Posts:64

| | 04/07/2008 3:54 AM |
| thanks John. I could not find any examples of an OR and this did not seem to work (note all 30 of my domains go to the same domain/result)).
[PB: IF(Match("[PB:Request.Url]","http://www.pokerdiy.co.uk") OR Match("[PB:Request.Url]","http://www.home-poker-tour.com") ) { [PB: Response.Status("301 Moved Permanently") ] [PB: Response.AddHeader("Location","http://www.pokerdiy.com") ] [PB: Response.End() ] }else{ }] | | | |
|
Rodney
 Posts:64

| | 04/07/2008 4:06 AM |
| | ps - I saw in another post that if you stack the IF statements in a single rule it acts as an IF ELSE (ie. exits on first match) - this is ideal as they all point at the same URL, but I think a big OR statement would be even more efficient... | | | |
|
John Mitchell Posts:2779


| | 04/07/2008 8:25 AM |
| Since all of your domains go to the same domain you can do it in one rule like this: [PB: IF( Match("[PB:Request.Url]","http://www\.pokerdiy\.com[/]?$") =="False" ) {
[PB: Response.Status("301 Moved Permanently") ]
[PB: Response.AddHeader("Location","http://www.pokerdiy.com/") ]
[PB: Response.End() ]
}else{
}] This makes every request for just a domain name that does not match http://www.pokerdiy.com or http://www.pokerdiy.com/ redirect plus you want to add that last slash to make it consistent. If you also want to redirect pages from the other urls to their corresponding pages (urls with Querystrings) then let me know, but I think it may be better if you push everything to the home page or it will look like you are trying to spam the search engines. | | | |
|
Rodney
 Posts:64

| | 04/07/2008 6:44 PM |
| Sorry to be think John (I'm very rusty on Regex!) - the match above seems to be going into an infinite loop for any legit PokerDIY URL with a page specified - eg. I was on this page - http://www.pokerdiy.com/Help/PokerAdvertising/tabid/388/Default.aspx and when I refreshed it showed:
"The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. * This problem can sometimes be caused by disabling or refusing to accept cookies."
My rule is as above (makes sense to me):
Search for:
[PB: IF( Match("[PB:Request.Url]","http://www\.pokerdiy\.com[/]?$") =="False" ) { [PB: Response.Status("301 Moved Permanently") ] [PB: Response.AddHeader("Location","http://www.pokerdiy.com/") ] [PB: Response.End() ] }else{ }]
Any ideas please?
| | | |
|
John Mitchell Posts:2779


| | 04/07/2008 9:02 PM |
| Oh wow. I messed that up. I was thinking that putting the end of the line character ($) would take care of not matching the pages with full Urls, but since it is negative logic, that just makes the condition true for any url that has a page name. I'll have to give that one some more thought but here is one closer to your original that should work:
[PB: IF(Match("[PB:Request.Url]","pokerdiy.co.uk|home-poker-tour.com" ) ) { [PB: Response.Status("301 Moved Permanently") ] [PB: Response.AddHeader("Location","http://www.pokerdiy.com") ] [PB: Response.End() ] }else{
}]
In the Match expression above the pipe symbol is a logical OR so pokerdiy.co.uk|home-poker-tour.com will match a url with either one of those domains in it (even if it has text on either side of the domain name.
| | | |
|
Rodney
 Posts:64

| | 04/08/2008 10:53 PM |
| Sorry, more questions John ;) Ok, I have all my 301 redirects set up – - With regards to your question a few posts up about preserving the URL or pushing to the homepage - Google has indexed some of the other domains already, so I think it may be better if I don’t just redirect to the main site (ie. www.pokerdiy.com/) – I just want to change the domain name and keep the rest of the URL
Eg. http://www.home-poker-tour.com/Leagues/PokerLeagues/tabid/435/Default.aspx should actually be http://www.pokerdiy.com/Leagues/PokerLeagues/tabid/435/Default.aspx but it’s indexed in Google as the dud domain (home-poker-tour.com) – so from what I understand about SEO it would be better to point this at the bottom link so that the reference in the index still has the same content, but Google can update their index to reflect PokerDIY.com instead because of the 301 redirect response. What do you think would be better? 2) 99% of the time the domain will be the correct PokerDIY.com (and over time this should improve as the 301 Redirect causes old links to be updated). I think it may be more efficient to check if it is “www.pokerdiy.com” first and do nothing, otherwise check the others. You mentioned that nested IFS are not possible, so would the below be a good idea? (it would not do the second check if the URL was www.pokerdiy.com). It seems to work but is it more efficient do you reckon? [PB: IF(Match("[PB:Request.Url]","www.pokerdiy.com"))
{[PB: Response.End()]}]
[PB: IF(Match("[PB:Request.Url]","wannaplaypoker.net|top-poker-deals.com")) {
[PB: Response.Status("301 Moved Permanently") ]
[PB: Response.AddHeader("Location","http://www.pokerdiy.com/") ]
[PB: Response.End() ]
}else{
}]
| | | |
|
Rodney
 Posts:64

| | 04/08/2008 10:59 PM |
| | Sorry, that last IF statement does not work (must have been caching) - how do I say "If it is www.pokerdiy.com then do nothing and let the response through as normal" | | | |
|
John Mitchell Posts:2779


| | 04/09/2008 7:47 AM |
| I don't have a way to stop processing a Rule based on a condition, but maybe I should add that.
To do what you are asking you can use:
[PB: IF( Match("[PB:Request.Url]","http://www.pokerdiy.com/") == "False" AND Match("[PB:Request.Url]","(wannaplaypoker.net|top-poker-deals.com)[/]?(.*)" ) ) { [PB: Response.Status("301 Moved Permanently") ] [PB: Response.AddHeader("Location","http://www.pokerdiy.com/$1") ] [PB: Response.End() ] }else{
}] | | | |
|
John Mitchell Posts:2779


| | 04/09/2008 8:13 AM |
| Ok, after looking at this again, you really don't need to check for all of your other domains if you want everything to go back to the main one.
So this should be all you need:
[PB: IF( Match("[PB:Request.Url]", "http://www.pokerdiy.com[/]?(.*)" ) == "False" ) { [PB: Response.Status("301 Moved Permanently") ] [PB: Response.AddHeader("Location","http://www.pokerdiy.com/$1") ] [PB: Response.End() ] }else{ /title> }] | | | |
|
Rodney
 Posts:64

| | 04/09/2008 9:19 PM |
| | Thanks John - works great... | | | |
|
Rodney
 Posts:64

| | 04/10/2008 11:54 PM |
| Actually John, I got it working with redirecting all pages to the home page ("http://www.pokerdiy.com/") but when I add the $1 to add the rest of the URL for other domains it does not work:
It outputs:
http://www.pokerdiy.com/$1 (which throws a 404 error of course). This was when I used the URL "http://www.rodneyjoyce.com/Resources/PokerGallery/tabid/558/PhotoId/2862/Default.aspx" and the rule as you specified above. I can't find anything about the $1 replacement var in the documentation...
How do I get it to put the URL instead of the $1? (I've changed the rule on PokerDIY back to going to the homepage in the meantime) | | | |
|
Rodney
 Posts:64

| | 04/14/2008 5:53 AM |
| | Just bumping this in case it got lost ;) | | | |
|
John Mitchell Posts:2779


| | 04/14/2008 8:03 AM |
| | Sorry, this one did slip past me. I'll have to setup my dev environment to try this out and get back to you. | | | |
|
John Mitchell Posts:2779


| | 04/14/2008 4:49 PM |
| Ok, I see why this isn't working as expected now. The group replacement requires that a match was found on the Match and we are looking for a match that is not found. I have another method simular to Match called Capture that will take care of this situation: [PB: IF( Capture("[PB:Request.Url]","http://([^/]+)/?(.*)" ) != "www.pokerdiy.com" ) {
[PB: Response.Status("301 Moved Permanently") ]
[PB:Response.AddHeader("Location","http://www.pokerydiy.com/$2")]
[PB: Response.End() ]
} else{
/title>
}] | | | |
|
Rodney
 Posts:64

| | 04/14/2008 6:19 PM |
| | Thanks for the attempt John, but unfortunately this rule does not seem work - it works if it is a different domain but as soon as you try to go anywhere with a URL it just hangs. I don't want you to waste too much time on this, so I may just point them all at the home page as before and eventually Google will catch up. | | | |
|
John Mitchell Posts:2779


| | 04/14/2008 7:29 PM |
| Darn, I tested it too. It worked for me, but I was just sending it to a different domain. I want this to work because it will probably be a pretty common request, so I'll keep trying until I get it right. | | | |
|
Rodney
 Posts:64

| | 04/15/2008 3:35 AM |
| | Ok, let me know thanks ;) | | | |
|