jdMorgan

msg:3383770 | 11:38 pm on Jul 1, 2007 (gmt 0) |
What were the results when you tested it? The "Live HTTP Headers" extension for Firefox/Mozilla browsers will answer your question quite unequivocally, without your having to take anyone's word for it. It's a great tool, and I recommend it. Jim
|
glenster73

msg:3383774 | 11:40 pm on Jul 1, 2007 (gmt 0) |
index.php redirected correctly to the homepage. I'd just like to know if this is the safe way to do things.
|
jdMorgan

msg:3383779 | 12:03 am on Jul 2, 2007 (gmt 0) |
OK. Yes it is. But without testing with a server header checker [livehttpheaders.mozdev.org], you're just taking "some guy on a Web site's word for it"... Jim
|
londrum

msg:3383789 | 12:26 am on Jul 2, 2007 (gmt 0) |
i've got this piece of php code which does the same thing - redirects example.com/index.php to example.com/ just stick it at the top of your page function index_url(){ if(preg_match('#(.*)index\.(html¦php)$#',$_SERVER['REQUEST_URI'],$captures)){ header('HTTP/1.1 301 Moved Permanently'); header('Location: '.$captures[1]); };} index_url();
|
glenster73

msg:3383827 | 2:42 am on Jul 2, 2007 (gmt 0) |
Thanks for the tips guys. Just in response to my second query: > Using .htaccess, what would I insert to redirect /search.php%3Ggo=adv to the homepage? This one is unusual in that obviously the % would normally be a?, so I am not sure where Google got that string from. Changing?strings can be done with the following example, but I can't get it to accept a % instead of a? Options +FollowSymLinks RewriteEngine on RewriteCond %{QUERY_STRING} ^productid=100001&cat=&page=1$ RewriteRule ^mydir/customer/product\.php$ http://www.example.com/mydir/customer/product.php?productid=100002&cat=&page=1 [R=301,L] Anyone with any clues on what I could try? cheers, G [edited by: jdMorgan at 6:14 pm (utc) on July 2, 2007] [edit reason] example.com [/edit]
|
jdMorgan

msg:3384399 | 6:25 pm on Jul 2, 2007 (gmt 0) |
| Using .htaccess, what would I insert to redirect /search.php%3Ggo=adv to the homepage? This one is unusual in that obviously the % would normally be a?, so I am not sure where Google got that string from. |
| It's even more unusual in that a question mark would normally be hex-encoded for transmission as "%3F", not "%3G", so there is a fairly big/serious bug somewhere in the code that generated that link. Because the server uses "?" to distinguish between the end of the URL and the beginning of the query string, and because the "?" is not present --having been replaced by a badly-coded hex-escape routine with "%3G"-- you won't be able to use the normal RewriteCond %{QUERY_STRING} solution. Instead, try %{THE_REQUEST} -- a variable which contains the raw (un-decoded) client request string:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /search\.php\%3Ggo=adv\ HTTP/ RewriteRule ^search\.php$ http://www.example.com/? [R=301,L]
Jim
|
glenster73

msg:3384579 | 11:15 pm on Jul 2, 2007 (gmt 0) |
That should read "search\.php\%3Fgo=adv" Sorry me bad. Seems my typing skills have a bug in them! In this case, do you know what the rewrite look like when the "?" is being converted to %3F? I tried both of the above without success.. cheers, G.
|
glenster73

msg:3384599 | 12:03 am on Jul 3, 2007 (gmt 0) |
Actually, this gets a little more complicated. Although I want to rid the search engines of "search.php%3Fgo=adv" and redirect it to the homepage, I actually have a valid page on my site named "search.php?go=adv" that I want to keep. Would any manipulation of %3F also cause the real page to redirect also? So, should I redirect the %3F version to the? version of the same page? If so, is there a correct syntax for doing that?
|
jdMorgan

msg:3384609 | 12:27 am on Jul 3, 2007 (gmt 0) |
# Redirect to fix invalid query string delimiter on any php page RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^.]+\.php\%3[Ff]([^\ ]*)\ HTTP/ RewriteRule ^([^.]+)\.php$ http://www.example.com/$1.php?%1 [R=301,L]
This rule will correct the "%3F" problem for any query string appended to any php page URL. It will take no action if the query string delimiter is valid. Jim
|
glenster73

msg:3384632 | 1:06 am on Jul 3, 2007 (gmt 0) |
Worked Jim! Well, sort of. The only thing I changed was the $1.php?%1 at the end of the domain. Your initial code caused /search.php%3Fgo=adv to redirect to /index.php?go=adv so I removed $1.php?%1 and it now redirects to the homepage. I don't think it affects anything else..
|
jdMorgan

msg:3384652 | 1:29 am on Jul 3, 2007 (gmt 0) |
> Your initial code caused /search.php%3Fgo=adv to redirect to /index.php?go=adv No... the code I posted didn't do that, since the "page name" is clearly copied directly from whatever page was requested. However, if you placed this code *after* another RewriteRule or used some other mod_alias Redirect or RedirectMatch directive, it is possible that the two interfered with each other. Standing alone, the rule will work exactly as described, changing nothing in the URL-path but the "%3F" to "?". I recommend you resolve this "mystery" because it threatens other unexplained problems down the road... Jim
|
glenster73

msg:3384665 | 1:41 am on Jul 3, 2007 (gmt 0) |
Yep, there's a whole heap of other stuff going on in my .htaccess so I will take a good hard look at that shortly. Thanks for the heads-up Jim. Just one other very strange URL I noticed in Google. Looks like it picked up an old cookie page that is no longer valid: www.example.com/?PHPSESSID=f9f2770d591366bc How would one convert that to just the homepage? cheers, G.
|
jdMorgan

msg:3385673 | 1:50 am on Jul 4, 2007 (gmt 0) |
My goal here is to help you learn to write your code, and not to write it for you. I simply can't afford to spend more than a few minutes a day here as a volunteer, and must allocate my time among many requests. And the same is true for the other contributors to this forum. So I would encourage (and ask) you to take the code above as an example, and try coding it yourself. For background information, please see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com]. Give it a shot, test it, and if you have problems, then please feel free to post back here. Thanks, Jim
|
glenster73

msg:3386454 | 11:33 pm on Jul 4, 2007 (gmt 0) |
cheers, I'll give it a go. I wasn't aware of the WebmasterWorld library - great resource! thanks for your efforts throughout the forums mate! G
|
|