Forum Moderators: phranque

Message Too Old, No Replies

can mod rewrite not change url if from google?

can mod rewrite be used to not change if the referrer is from google

         

sasori

5:22 pm on Aug 20, 2009 (gmt 0)

10+ Year Member



Hello, I've discovered an issue that I'm having trouble resolving:
This is my current mod rewrite:
RewriteEngineOn
RewriteBase/online_store
RewriteRule^products/([0-9a-zA-Z\_\-]*)\.htm([l]?)$index.php?p=product&product_code=$1 [L]
RewriteRule^catalog/([0-9a-zA-Z\_\-]*)\.htm([l]?)$index.php?p=catalog&catalog_code=$1 [L]
RewriteRule^pages/([0-9a-zA-Z\_\-]*)\.htm([l]?)$index.php?p=page&page_id=$1 [L]
RewriteRule^index\.htm([l]?)$index.php?p=home [L]
RewriteRule^site_map\.htm([l]?)$index.php?p=site_map [L]
----------------------------------------
This is a link that is on froogle.com, from a previous upload:
http://www.example.com/index.php?p=product&id=131&parent=122

can the RewriteRule(s) be skipped if the referrer is from:
http://www.google.com/product_url?q=http://www.example.com/index.php%3Fp%3Dproduct%26id%3D131%26parent%3D122~~blah blah blah

Thanks!

[edited by: jdMorgan at 8:20 pm (utc) on Aug. 20, 2009]
[edit reason] please use example.com only (See Terms of Service) [/edit]

jdMorgan

8:21 pm on Aug 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All of your RewriteRules are already "skipped" for that request with *any* referrer, because none of your rule
patterns will match the "index.php" in that requested URL.

Based on the fact that you rewrite other URLs *to* index.php, it appears that the old Froogle link is not rewritten at all, it simply goes direct to index.php.

So I suspect you'll need to ask a different question here, because we don't know what you want to happen when that old Froogle link is requested.

Jim

g1smd

8:48 pm on Aug 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's some other problems with the code as I see it:

You'll likely need to swap the * for a + as * means "zero or more". You don't want to match a URL request like

example.co[b]m/.h[/b]tml
as your script can't fulfill that.

Additionally, don't let both .html and .htm URLs feed your rewrite. Place a redirect ahead of your rewrites so that if .html is requested, the user is redirected to the equivalent .html URL.

sasori

9:49 pm on Aug 20, 2009 (gmt 0)

10+ Year Member



hmm, perhaps its a setting in the php, then. since the url gets passed, its not getting 'seen' because the script is expecting the 'flattened' url only.
Sorry I didn't figure that out earlier.

If I set the script to accept either type of url, will I be messing up SEO since there are two ways to get to the same page? I know, I know, the 'flattened' url line needs to be switched from underscores to dashes for better SEO.

thanks

g1smd

10:36 pm on Aug 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Note that "two ways to get to the same page" is Duplicate Content.

That applies to www and non-www. I already warned you about the .html and .htm in your rewrites. You need to fix those, as well as not create any more such problems; so do not alter your script to accept multiple URLs.

Link to the correct URL. It is links that 'define' URLs. Set up a redirect to catch requests for incorrect URLs and redirect them to the correct URL.

sasori

7:16 pm on Aug 21, 2009 (gmt 0)

10+ Year Member



Thanks for your advice. I've already changed
htm([l]?) to html
I also changed * to + and all seems to work OK.

I'll research into the redirect, now.

Thanks