Rewrite URL to remove first page pagination using htaccess - .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.

Related

How to make SEO friendly URL using .htaccess

I want to make this URL
https://www.maxelplus.com/single-commercial.php?PId=Mjc&Title=Domestic%20Products
to
https://www.maxelplus.com/domestic-products/table-top-wet-grinders/sleek-table-top-wet-grinder-2l-LEP883/
I used below code but is not working.
RewriteRule ^domestic-products/table-top-wet-grinders/sleek-table-top-wet-grinder-2l-LEP883/$ single-commercial.php?PId=$1&title=$2 [QSA]
Please share whate i am missing..
Depending on how your website is being hosted, it might be helpful to look at the .htaccess permalink structure which can be found here.
It looks like your first link is using a custom structure permalink, but your desired URL is a combination between post name and product number. A generic set of instructions can be found here if you are using WordPress. This can also clarify the benefits of using URLs that are friendly for Search Engine Optimization (SEO).

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

Url duplication with Prestashop SEO

I have an e-commerce developed with the CMS Prestashop.
Yesterday i have seen in my Webmaster Tools that i had some duplicated URL, like this:
www.mysite.com/manufacturers
www.mysite.com/it/manufacturers.
Where 'it' is the suffix of the default and only language for the website.
I've already activate the friendly URL in the back-office and also I've a .htaccess file generated automatically by the generator in the back-office.
What should I do to fix this issue?
PS: Also I think that I've already taken a penalization from googlebot.
First of all let me clarify the Title from the SEO point of view. The problem is from Prestashop side not from SEO side. It is just affecting your SEO.
Now on the problem, Prestashop is notorious for URL problems. I would not recommend you the .htaccess hack solution because every time you regenerate your .htaccess from you backend, you have to manually insert that hack again in it to keep the problem down. And suppose this url problem arises again after sometime for some other url than you have to do it again. It can turn into a nightmare.
So here are some of my personal recommendations...
If this site is critical(which I am assuming), buy a Prestashop url rewriting module from a trusted provider. You will also get a technical support in case this problem arises again in future.
If you can't buy than I would suggest you to ask this question on Prestashop forums, as this is Prestashop specific, to permanently solve this problem. You will most likely to get more instant answers as you will find more people working on Prestashop there than here.
Somewhere either in the htaccess file in your document root, or in the vhost/server config for mysite.com, you'll need to 301 redirect. Now you just need to choose which one you want to keep, the one with /it/ in front or the one without? Let's say you want to point everything to the one without, you'll use one of these:
Using mod_alias:
Redirect 301 /it/manufacturers /manufacturers
Using mod_rewrite:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mysite.com$ [NC]
RewriteRule ^/?it/manufacturers(.*)$ /manufacturers$1 [L,R=301]

How to Redirect URL except GoogleBot?

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.

Resources