How to block all .xyz referral spam using htaccess? - .htaccess

There is a large list of .xyz referral spam domains in my GA.
I can name them all separately in my .htaccess, but I want to block them all forever.
How can I block them all using 1 line in my .htaccess?

Related

How to ignore/redirect all URLs matching a certain string

I am using the Wordpress plugin, Timely All-in-One events calendar. Unfortunately it is creating a plethora of duplicate URLs which end in strings like (https://www.mywebsite.com/events/action~agenda/page_offset~-2/request_format~json/cat_ids~4) or (https://www.mywebsite.com/events/action~oneday/exact_date~2-4-2019/) for example.
As a consequence of these URL directives each being for a different calendar view but containing the same webpage title and content, some search engines are seeing this as duplicate content. Whilst robots.txt is setup to tell bots to ignore the URLs containing said strings, some crawlers are ignoring robots.txt. I have also disabled the various different calendar views so there is now only the agenda view but even in spite of this, bots continue to crawl these URLs.
Therefore is it possible to use Apache/ a .htaccess directive to tell the server to direct any requests containing "/action~" to either remove the string from the URL so the browser just reads "/events/" or to redirect/forward the URLs to another page.
There are over 500 of these URLs so I ideally would like a quick remedy!
Thanks in advance.
Check this rewrite in your .htaccess file
RewriteEngine On
RewriteRule ^events\/action(.*)$ /events/ [L,R=301]

What is the correct method to 301 redirect 500+ pages

I need to redirect 500+ pages. The original url references the product id, now they want it to reference the product name. For example:
from:
www.thedomain.com/bn/products/product-details/72
to:
www.thedomain.com/bn/products/product-details/MR633
I know the rewrite rule needs to be:
RewriteRule ^/bn/products/product-detail/72$ http://www.thedomain.com/bn/products/product-detail/MR633 [R=301]
Will I need to create all 500+ redirect lines manually to add to the htaccess file, or is there a different, better approach? Google has indexed all 500+ pages, so they don't want to lose that juice. Any recommendations would be appreciated.
Also, is it OK/normal to have hundreds of redirects in an .htaccess file?

htaccess maximum number lines for perfomance considerations

As a result of merging several sites together, I have a couple of thousand pages that need to be redirected. I cannot use wildcards as they are specific pages, so they will all be the form of:
Redirect 301 /old_page.html http://www.example.com/new_page.html
Is there a recommendation on how many lines can be in the .htaccess file before it starts to become a performance issue? I'm sure it depends somewhat on the apache configuration, system memory, etc. but I'm trying to get an estimate. Is 2,000 lines too long, or should it be 200, or is 20,000 okay?
I have a couple of thousand pages that need to be redirected. I cannot use wildcards as they are specific pages, so they will all be the form of:
Redirect 301 /old_page.html http://www.site.com/new_page.html
Nope, don't do that.
Redirect everything (expect maybe static ressources like js, css, images, ... that have not changed) for that no current content can be found to a script instead - and have that look up the new URL corresponding to the old one requested, and then does a redirect with a Location header.

The trailing slash in home page

I will be really greatful if someone helps me with this.
Let's consider these 2 URLs (both returning 200 in the response header):
www.foo.com/something
www.foo.com/something/
Google considers these 2 URLs different despite both having the same content which leads to a duplicated content problem. To solve the issue it is advised to either use the 301 permanent redirect to redirect one URL to the other or use the rel="canonical" attribute. source
Wordpress blogs deal perfectly with this matter. When adding the trailing slash to my internal links, I was redirected to URLs without the trailing slash (301 response).
The problem is the redirect is only happening with internal pages. My homepage seem to return a 200 response with or without the trailing slash. Should I leave it as it is or force a redirect with the .htaccess file?
p.s.: The backlinks to my website have 2 different hrefs (with and without the trailing slash). Should I change those backlinks to a unique href or redirect one to the other?
Use this link to add trailing slash to end of your url
It doesn't matter whether your Backlinks are with slash or not, because after implementing techniques mentioned in above address, search engines will assume your pages only with slashes. Remember because of past indexing you should wait until former index to be deleted. or you may use 301 redirect to pages with slash. Basically this will take some time until search engines came again and find your redirect rules, too... .
By home page I assume you mean the page shown when you enter just the domain.
With or without the slash represents exactly the same URL. Nothing to worry about and nothing you can do.

How can I block visitors from a specific country with htaccess?

Is there any way of blocking my site to visitors that come from certain countries using the htaccess file? If possible, how should the line(s) of code look like?

Resources