Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite created duplicate Google listings...

Is there any way to 301 them?

         

Tippy

4:56 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



Hi,

I recently used mod_rewrite to change my dynamic URI's to static ones, such that
[mysite.com...]
becomes the 'real' page at
[mysite.com...]

Google picks up the nice new short format, but it had already indexed the dynamic URIs and now lists two sets of identical pages bar the URI. The .php?get=XXX versions are never going to 'fade out', because they're obviously always going to be valid, but I'd really rather hide their existence completely in favour of the .html version.

Is it possible to do some whacky mod_rewrite voodoo to rewrite the incoming URI from the dynamic form with a redirect 301 to the static form, which would hopefully flag Google to drop the page, and then rewrite the URI as above 'silently', so that the nice static URI remains in the address bar?

I'd imagined doing something like:

RewriteEngine on
RewriteRule ^displaywidget\.php\?get=(.*) /widget$1.html [NC,R=301]
RewriteRule ^widget(.*)\.html /displaywidget.php?get=$1 [NC,L]

but to no avail.

I'm sorry if this has been answered already, but I can't find the proper techie terms to describe the problem so I'm having no luck searching.

P.S. I know it sounds like a solution in search of a problem, but I took a significant rankings hit after the change so I'm trying to get everything back as close to the previous state of affairs as possible.

closed

5:56 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



I'd just use robots.txt in this case and disallow access to the PHP files.

Tippy

10:10 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



The noise you currently hear is my hand slapping repeatedly against my forehead.

I seem to be picking up a bad habit of trying to use a hammer to do a screwdrivers' job!

Thanks, closed.

closed

5:55 am on Mar 15, 2004 (gmt 0)

10+ Year Member



That isn't the end of it, though.

You'd still have to make sure that all the links to the .php?get=XXX pages are replaced with links to the new pages. Otherwise, you'll still get duplicate listings and the PR would be divided between the two.

Using mod_rewrite would have been easier if there was a way to stop the infinite loop. I know a way to do it, but since most of the links to your .php pages were on your site anyway, I recommended the easy way out. :)

You're welcome, Tippy.

rogerdp

6:51 am on Mar 15, 2004 (gmt 0)

10+ Year Member



Why are you using .html? Just drop it.

Doesn't adding the L(ast) flag on both stop the loop?

closed

3:06 am on Mar 17, 2004 (gmt 0)

10+ Year Member



Doesn't adding the L(ast) flag on both stop the loop?

Probably not.

jdMorgan

12:16 am on Mar 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The [L] flag stops the rewriting for the current HTTP request, but does not stop rewriting for additional internal subrequests which traverse the directory in which the rewrite code resides.

It also has no effect on any other HTTP request. Since these are 301 redirects, the server will send the 301 response back to the client browser, giving it the new address of the requested resource. The client browser will then issue a new HTTP request for the resource at the new address.

So that's why [L] won't "stop the loop."

Jim