Jump to content

Archived

This topic is now archived and is closed to further replies.

phbock

Help with %3F and rewrite htaccess

Recommended Posts

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[b][/b]

Share this post


Link to post
Share on other sites
If you want to rewrite a url you would need to add the following to your htaccess

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

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

Share this post


Link to post
Share on other sites
[quote author=phbock link=topic=101628.msg402349#msg402349 date=1153724521]
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[b][/b]
[/quote]
The %3f and %3D are the [url=http://www.php.net/urlencode]urlencoded[/url] 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[quote author=phbock link=topic=101628.msg402625#msg402625 date=1153756030]
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
[/quote]
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.
[code]
<?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;
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.