Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Google found actual scripts even though I have URL rewrite!



7:33 pm on Nov 20, 2010 (gmt 0)

5+ Year Member

We rewrite all of our URLs using mod_rewrite with htaccess.

Somehow google found the actual pages that the rewrites use, and so now there is duplicate content on every page.

Our rewrites are done in a simple way:

RewriteRule ^page/(.*).html$ /scripts/widget.php?color=$1 [L]

We checked and checked and there is no link anywhere that does not use the rewritten URLs.

Does anyone know any way this might have happened, so we can fix his? Apparently if you type in the rewritten URL into the browser, on some rare occassions it redirects you to the script URL. I've only been able to replicate this one. No idea how this happens, but this must have been how Google discovered this.

Any help is appreciated, thanks!


10:15 pm on Nov 20, 2010 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Yes, you can set a redirect to fix this. It's one of the most popular topics in this forum. There's hundreds of prior threads with example code.

Additionally your existing code would benefit with the (.*) pattern changing to ([^.]+) or similar. It will operate a lot more quickly.


1:09 am on Nov 21, 2010 (gmt 0)

5+ Year Member

Thanks g1smd! Can you give me a search term to search for? I keep getting irrelevant results... thanks!


4:14 pm on Nov 22, 2010 (gmt 0)

5+ Year Member

Anyone know a search term? :)


11:26 pm on Nov 24, 2010 (gmt 0)

5+ Year Member

c'mon guys, help out a newbie :)


7:47 am on Nov 27, 2010 (gmt 0)

5+ Year Member

Some good examples and detailed info on htaccess usages

[corz.org ]


10:34 pm on Dec 1, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Please see our Apache Forum Charter and our Apache Forum Library for (a lot) more info.

# Externally redirect only direct client requests for script filepath back to search-friendly URL
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /scripts/widget\.php\?color=([^&\ ]+)\ HTTP/
RewriteRule ^scripts/widget\.php$ http://www.example.com/page/%1.html? [R=301,L]
# Internally rewrite search-friendly widget requests to script
RewriteRule ^page/([^.]+)\.html$ /scripts/widget.php?color=$1 [L]

This code works if and only if "color" is the only query string parameter. For additional parameter support, you will need to provide more information.


Featured Threads

Hot Threads This Week

Hot Threads This Month