How to Redirect URL except GoogleBot? - .htaccess

I have a highly rank post on my blog and I just want to redirect it to my ClickBank affiliate link without losing my rankings. So I need to do this with .htaccess file.
First it must check the USER AGENT,then it must check is there any "GOOGLE" word on that user agent string. If not, it should redirect user to my affiliate link. So far I tried following code without any success.
RewriteCond %{HTTP_USER_AGENT} ^((?!google).)*$
RewriteRule http://myblog.com/post/ http://myafflink.com [R=301,L]
Please help.

Isn't it similar to doorway approach which will finnaly lead you to ban in google?
It' not a good practice to show different pages to users and search engines.

Related

Hiding some GET parameters from URL

I am redirecting page using PHP header location:
Current URL in browser
https://mywebsite/open/firstpage/php/start.php?&cnt=us&language=en&url=http://secureURL.com
but want to show
https://mywebsite/open/firstpage/php/start.php?&cnt=us&language=en
I am using GET method on the other side to collect all variables. I have to hide &url in querystring but want to receive it on other side $_GET['url']
How can I share my &url without showing in URL querystring? HOw can I write htaccess?
Redirect for all URLs
RewriteEngine on
RewriteRule ^(.*) $1?%{QUERY_STRING}&url=http://secureURL.com [L]
Redirect for only /open/firstpage/php/start.php
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/open/firstpage/php/start.php
RewriteRule ^(.*) $1?%{QUERY_STRING}&url=http://secureURL.com [L]
I think this is what you want.
You can't do that. If a parameter is not present in the query string, it won't be available anywhere, it's just not there. There's no such thing as "hiding" the query string.
You could, however, use some form of session mechanism to pass a piece of data from one page to another. You could put it in the $_SESSION, or use cookies. There may also be a way to achieve this through really arcane mod_rewrite magic, but you shouldn't go down that route. Really.
More importantly: what are you trying to achieve? Why are you trying to do this?
Aesthetic reasons? Then be aware that modern browsers tend to hide the query string part of the URI from the user.
Security reasons? Then you're doing it horribly wrong, you shouldn't use something so easily manipulated by the client.
User tracking? There are established solutions out there for that (say, Google Analytics).

whitelist specific websites in htaccess

I have a problem in one of my websites. I'm using a custom made php script to protect my images from being hot linked by new Google Image Search. The script is working but it blocks all other websites from hotlinking, including Facebook, Google Plus, pinterest ...
Therefore please help me on how to whitelist at least these three websites in my htaccess file: facebook, google plus and pinterest.
I tried for example this:
RewriteCond %{HTTP_REFERER} !^http://plus.google.com\. [NC]
RewriteCond %{HTTP_REFERER} !^https://plus.google.com\. [NC]
for google plus .. but looks like it does't work ... what i'm missing here ... ?
Thank you very much
Anyway, what you want is something like the following rule:
RewriteCond %{HTTP_REFERER} !^http(s)?://plus.google.com [NC]
I'm not sure why your rule has a \. at the end of the URL but this does really not seem appropriate there.
You can also reduced it to one rule through the http(s)? part of the new rule.
But please, think really hard about what you want to do there. Instead of preventing hotlinking by Google, you should either consider robots.txt rules or just allowing Google to link to your images. Everything else can (and probably will with some Google update) harm your sites rank in Google, as you use something that could be easily filed under 'cloaking', which in return would get your whole page marked as spam in the Google index. You can read more on the subject there: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66355

Changing a website domain and redirecting

We're moving a fairly large website from domain.one where it's been for a long time onto domain.two. If people still find links for domain.one we want them to redirect to an appropriate place on domain.two (if possible).
Domian.one is no longer required after the switch. I don't know anything about moving an entire domain so could use some advice on the best way to go about switching whilst retaining the SEO gained over the years.
Any help is appreciated.
Many thanks
Put this in an htaccess file in your root web directory. It will forward your users, and search engines, to the new URL on the new domain.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
ADD THE FOLLOWING LINES as posted by John .
Also log in to google webmaster tools->configuration->change of address
and change your url ther so that seacrh engine results are also changed.
THIS iS VERY IMPORTANT

Best way to change domain names

I have a blog which i get about 1200 visits a month lets say the blog domain name is.
exampleblog.com
What i want to do is complete change the domain name to say.
iamsam.com
What is the correct way to do this should i map the domain iamsam.com to my exampleblog.com account on my hosting then put a 301 redirect in the htaccess to redirect traffic to the correct domain ie.
Options +FollowSymlinks
rewritecond %{http_host} ^exampleblog.com [nc]
rewriterule ^(.*)$ http://www.iamsam.com/$1 [r=301,nc]
Is this the correct way to do this???
Can someone advise me thanks
Yes, that is exactly the way to do it, assuming the URL scheme for the new domain is exactly the same as the old domain.
You might also want to capture users that use the old address and display some sort of notification on the new website, so that they'll notice the change and update their bookmarks.

Rewrite URL to remove first page pagination using htaccess

I have an paginated list of articles and my search engine is indexing the first page twice as /articles and /articles?start=1.
I want to write an .htaccess rewrite rule to rewrite any requests for /articles?start=1 to /articles to stop this from happening.
There are a couple of other article based paginated lists on the site, so i need to match just the parameter rather that the full url, so that the rule will work on thse urls also.
Thanks for your help!
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} \/articles\/
RewriteCond %{QUERY_STRING} start=1
RewriteRule (.*)$ /index.php\?
I am assuming articles is a directory.
A bit of a necro, but I just found this question via Google when looking for something else.
Recently, Google offered up way more control over how URL parameters affect their indexing of your site. Go to Google Webmaster Tools and set up your site.
Google will crawl your site and add a list of URL parameters its aware of (and I beleive you can add your own to the list). You can specify how the URL parameters affect your page (pagination, filtering, internal etc) which in turn tells Google how to index it.
In this case, you'll be able to say that start should be either ignored, indexed only once, or treated how you see fit to make sure it only appears how its meant to in the index.
This helps Google and also helps you, so its entirely win-win.

Resources