Jump to content


Photo

Help with %3F and rewrite htaccess


  • Please log in to reply
4 replies to this topic

#1 phbock

phbock
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 24 July 2006 - 07:02 AM

Hi,

looking for help on:

if I go to Google's cache of my site (s)he gives me an error message. The cause might be in the fact that google looks for
mysite/main.php%3Fcmd%3Dhelp

instead of

mysite/main.php?cmd=help

can i fix that? Say with an htaccess entry?

(Running apache php mysql on a shared server with godaddy)

thx a lot
Phillip

#2 tyrant1337

tyrant1337
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationBleakpool

Posted 24 July 2006 - 10:28 AM

If you want to rewrite a url you would need to add the following to your htaccess

RewriteEngine on
RewriteRule ^main/([A-Za-z0-9-]+)/?$ /main.php?cmd=$1 [nc]

You'll end up with the url mysite/main/help/

#3 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 24 July 2006 - 02:35 PM

Hi,

looking for help on:

if I go to Google's cache of my site (s)he gives me an error message. The cause might be in the fact that google looks for
mysite/main.php%3Fcmd%3Dhelp

instead of

mysite/main.php?cmd=help

can i fix that? Say with an htaccess entry?

(Running apache php mysql on a shared server with godaddy)

thx a lot
Phillip

The %3f and %3D are the urlencoded values for ? and =. You see them in the url when you're looking at the cached version because google passes them as part of an argument in the query string. Because of their special meaning in the query string they are encoded to avoid ambiguity.

If you look at the cached version of other pages that have a query string, you should see the same thing.

#4 phbock

phbock
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 24 July 2006 - 03:47 PM

shoz,

I somehow figured that. My question is: How is googlebot sending the request?

If I punch in the %3F version my php script does not read that properly. Is that a problem?

thx
Phillip

#5 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 24 July 2006 - 04:57 PM

shoz,

I somehow figured that. My question is: How is googlebot sending the request?

If I punch in the %3F version my php script does not read that properly. Is that a problem?

thx
Phillip

The %3F is only passed to google's script/app and what it receives is "?" and "=" not "%3f" and "%3d". The output of the cached version of the page is then sent to you. Google should have no interaction with your page when sending you the cached version.

When googlebot is indexing your site it sends the request properly.

This is an example to demonstrate what googles cache app receives.
<?php
if (isset($_GET['url']))
{
    echo "Look at the url. You should see %3f etc if you entered a url with a query string<br  /><br />\n\n";
    echo "This is the url the script received: " .$_GET['url'];
}
else
{
   echo <<<NNN
<form action="{$_SERVER['SCRIPT_NAME']}" method="get">
<p>
Enter a url. eg: "www.foo.com/index.php?cmd=help<br />
<input name="url" type="text" value="enter a url" />
<input type="submit" value="submit">
</p>
</form>
NNN;
}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users