Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite and Google Maps

Does Google Maps understand rewrites?

         

flamingsole

3:04 am on Jun 1, 2007 (gmt 0)

10+ Year Member



I'm currently making a site that uses mod rewrite to redirect urls. So, [domain.com...] would redirect to [domain.com...] This site also uses Google Maps. The Google Maps API key is good for a single directory.

So my question is, do I get a key for the root directory only, or do I need to get a key for the rewrite 'directories' that aren't really directories? If, for example, I wanted to post a map at [domain.com...] would I need a key for this or does it understand that there really isn't such a directory?

I apologize if this is a stupid question. It doesn't make sense to me that the API would not understand this, but it seems to be a question worth asking.

Thanks.

ahmedtheking

11:07 am on Jun 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To be honest, all things would say that a base dir API should work, but because it's JavaScript and it gets the URL through that, it may affect Google Maps. The only way is to try really.

phranque

11:06 pm on Jun 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



the google maps request is made by the browser so it depends on the referring url that is shown in the browser.
perhaps you could hide the rewrite so the browser is not aware of the "directory" using by using an internal redirect.

jdMorgan

11:51 pm on Jun 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This right here is the problem:
I'm currently making a site that uses mod rewrite to redirect urls. So, http://example.com/1/2/3 would redirect to http://example.com/index.php?category=1&page=2&subpage=3.

If you are using a redirect, rather than an internal rewrite --and mod_rewrite can do either-- then the index.php script URL gets 'exposed' to the client, which in the case of a search engine spider, will result in the index.php script URL getting listed as a the 'real' URL.

Use an internal rewrite instead, and clients will be completely unaware that you're using a script to generate the pages, and example.com/1/2/3 becomes the 'real' URL.

Tutorial: [webmasterworld.com...]

Jim

[edited by: jdMorgan at 11:52 pm (utc) on June 4, 2007]

phranque

12:05 am on Jun 5, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



me:
using an internal redirect.

jim:

If you are using a redirect, rather than an internal rewrite

what he said!
i meant to write "internal rewrite"...

jdMorgan

2:56 am on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Even the Apache documentation adds to the confusion by frequently using the term "internal redirect" instead of "internal rewrite."

The most explicit way to put it is that an external redirect is a server response sent to the client. This response ends the client's initial HTTP request. If the client cooperates and issues a second HTTP request using the new URL given in the server's initial redirect response, then a URL-to-URL translation is effected.

An internal rewrite is simply a non-default URL-to-filename translation, and occurs entirely inside the server and within the context of the client's initial HTTP request.

Jim

phranque

5:45 am on Jun 5, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Even the Apache documentation adds to the confusion by frequently using the term "internal redirect" instead of "internal rewrite."

that is exactly where i picked up that bad habit...

LifeinAsia

3:35 pm on Jun 5, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



So have you actually tried registering a key for the root domain (e.g., [domain.com...] and then trying it in a subdirectory? It's a relatively painless process and then you'd have the definitive answer. :)

flamingsole

2:58 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



Sorry to resurrect this thread, but in case it ever comes up again, Google Maps doesn't appear to be fooled by mod rewrite. I'm using, roughly, the following syntax:

RewriteRule /*index\.php - [L]
RewriteRule ^index/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?category=$1&page=$2&subpage=$3 [L]
RewriteRule ^index/([^/]+)/([^/]+)/?$ /index.php?category=$1&page=$2&subpage=default_page [L]

My Maps API key is registered for the root of the domain, and thus far it's being used two "directories" down from the root, in www.example.com/category/page/. No issues have arisen from this.

Thanks for your input.

flamingsole

2:59 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



Also, as an afterthought, if you have a key registered for www.example.com, and were to try to use it in an actual directory of www.example.com/admin/, you would receive errors. So, it appears to actually be the mod rewrite that Google sees through, rather than it being indifferent to real directory structures.

jdMorgan

3:12 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Google sees URLs, not file structures. As long as nothing in your mod_rewrite code or scripts does a redirect that exposes the actual file structure, Google will never know about your file structure.

URLs and filepaths can be and most often are completely-different things. Does Google know the name of the disk that your files are located on? No. Does it know your "account name" on the server -- like "/users/your-site/htdocs"? No. That's because the server consistently hides this part of the filepath. But beyond that level, it is up to you to implement your rewrites, redirects, and scripts so that your server filepaths remain hidden. This is why I previously emphasized the important distinction between an internal rewrite and an external redirect.

Look for a redirect response (301 or 302) from your rules or from your script(s) that is 'exposing' the real directory path to Google.

Jim

phranque

10:55 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Look for a redirect response (301 or 302) from your rules or from your script(s) that is 'exposing' the real directory path to Google.

i often us lwp-request for this purpose:
lwp-request -Sd http://www.example.com

the -S option displays the status chain and the -d option excludes the document output from the printed response.

typical results might look like:

GET http://www.example.com/1/2/3 --> 301 Moved Permanently
GET http://example.com/1/2/3 --> 302 Found
GET http://example.com/index.php?category=1&page=2&subpage=3 --> 200 OK