PDA

View Full Version : .htaccess help


SunniOne
09-04-2009, 05:51 PM
Can someone please tell me what I'm doing wrong? This is what I have in my .htaccess file:


RewriteEngine on

RewriteCond %{HTTP_HOST} ^websitename.com$
RewriteRule ^/?$ "http\:\/\/www\.websitename\.com" [R=301,L]

RewriteCond %{http_referer} ^http://([^.]+\.)*(google)\.com
RewriteRule ^$ portal.html [R=302,L]

The first one works, the second one does not.

abduraooft
09-05-2009, 06:26 AM
The first one works, the second one does not. It'd be easy for us, if you describe what you actually want to achieve.

SunniOne
09-05-2009, 02:21 PM
It'd be easy for us, if you describe what you actually want to achieve.

You're absolutely right. My apologies. Sometimes my fingers move faster than my brain.

The first is just a redirect without www

For the second one, I'm trying redirect any traffic from Google to a portal page. My client's business was somehow linked to a book he wrote and visitors aren't getting to the business link. We're putting in a portal page so they can access the business if that's what they intended.

clunk.werclick
09-08-2009, 08:47 PM
I'm no expert on this stuff, but a couple of things jump out / worth a mention.

1. You are seeing this referer string in your logs? (Nothing is blocking it???)
2. Testing your regex matches the google referer in one tool for me - but in another it fails. In the first match line do you need to escape the forward slashes?? \/\/ ?
3. Does this do anything?
RewriteRule ^(.*)$ http://absolute.url/portal.html [R=302,L]

What *actually* happens when you get a referer from google? Do they get a missing page or see the original page sent to? That is, are they redirected at all? Do you see the referer in the logs?

If you've solved this - please share it as it helps others who google :-)