I started my blog a few days ago, and after publishing a few articles, I wanted to create backlinks. Doing that, I found a site called blogarama.com. I didn't check reviews first and added my site to it. That site adds my articles directly to it and gives backlinks to them. After a few days, I noticed increased traffic on my site from that site. But then I checked reviews of that site, and they said it sends bot traffic and harms sites. I tried to remove my site from that site, but there was no option. I even try to mail them, but that's also not working. Then I find that I can block sites in my htaccess, but I don't know how to. Please help.
I try to block that site in google analytics, but that's not working.
Adding this will work?
RewriteEngine on RewriteCond %{HTTP_REFERER} blogarama.com [NC,OR]
RewriteCond %{HTTP_REFERER} www.blogarama.com RewriteRule .* - [F]
Change the domain in the first line of the rule to target the domain you wish to block.
SetEnvIfNoCase Referer "siteNameTobeBlack.com" bad_referer
Order Allow,Deny
Allow from ALL
Deny from env=bad_referer
Ensure mod_setenvif directives enabled
Related
I have a client whose website develops & sells retirement villages in multiple locations, it's a Wordpress Multisite, with the main site being generic and the subsites are all the different locations. Basically we want to have an abbreviated domain for each location for advertising purposes that takes visitors to the correct location subsite, without changing the url, because we don't want to have to purchase SSL for every single domain/subsite.
so basically
locationA.com
when entered in the address bar goes to
https://mainsite.com/locationA
without changing the subsite url in the browser to LocationA.com - I know how to change the subsite domain via the wordpress admin settings but we don't want to change permalinks/urls unless there is absolutely no other way.
All the domains are parked at the mainsite's hosting,
I've tried redirecting via the cPanel Alias settings going to https://mainsite.com/locationA, but it always just takes us to https://mainsite.com/
RewriteCond %{HTTP_HOST} ^locationA\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.locationA\.com$
RewriteRule ^/?$ "https\:\/\/mainsite\.com\/locationA\/" [R=301,L]
I've tried other various .htaccess edits from other forums but they either break the site or just do the same thing as above and takes us to the generic mainsite.
e.g.
RewriteBase /
RewriteCond %{HTTP_HOST} ^locationA\.com$ [NC]
RewriteRule ^(.*)$ https://mainsite.com/locationA/ [L]
I don't really know what I'm doing with these, just trying things until something works.
Any help or insight would be greatly appreciated, thanks!
Nevermind, fixed it myself. The problem was that I added the domains as an 'Alias', redirection via CPanel worked when I added them as 'Addon Domains' instead.
I am building a new site for a client. we preserved the old site in a wordpress multisitesolution. Now it's time to migrate into the new site. Problem is the old site is heavilly embedded in Google Search with many active links. So I need a way to catch and redirect each and every link that comes our way.
I can redirect old.sitename.com to new.sitename.com directly - this works fine. Problem is when I get direct links to posts or pages.
Som this is the syntax I need resolved
old.sitename.com/an-article-read-this --> new.sitename.com/an-article-read-this
I have tried several .htaccess commands, including a few wordpress addons. Even simple ssl with .htaccess redirect enabled.
RewriteRule ^old.*$\% https://hoppla.heiledeg.no/%{REQUEST_URI} [R=302,NC]
direct links keeps opening up in the old site. not the new one.
Yes I have refreshed cache. And even tested on "fresh" browsers.
Any ideas, tips, or even addons are very much appreciated.
for me this was the solution:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(old.)?olddomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
I want to block direct access to my website.
If the visitor comes from the search engines, can view the site.
If you try to enter the site address directly into the address bar, go to a different page.
How can i do this with htaccess?
I had many trials before. But there was alot of mistakes. Finally, i tried this code :
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^
RewriteRule ^ https://my_domain.com/error_page/ [NC]
If there is no referer tag, it goes to error page.
TL;DR: I want to redirect https to http on all pages except for admin/login, where I want the exact opposite to happen. I also want www redirected to bare domain name. (UPDATE: Check Update 3 for the answer)
As is probably clear from the title, I have a Wordpress blog hosted on OpenShift for free. I have a custom domain bought from GoDaddy. I'm using cloudflare so I can have free SSL.
Here's my configuration:
CloudFlare DNS:
CloudFlare Page Rules:
This is what worked best. I actually wanted to have this rule:
*ghostlessmachine.com/* -> https://ghostlessmachine.com/$1
But I ran into even more problems like that, even though it seems to be pretty much what I'm supposed to do according to this CloudFlare article. Actually, initially I wanted to only force SSL in admin pages, but I didn't even know how to attempt that. I thought of using two page rules, like this:
*ghostlessmachine.com/* -> http://ghostlessmachine.com/$2
*ghostlessmachine.com/wp-* -> http://ghostlessmachine.com/$2
But I had no luck.
Here's my OpenShift configuration:
When I write ghostlessmachine.com in my address bar, it correctly takes me to https:.... I have shared a link, however (https://ghost...), and one person has reported not being able to access it. I couldn't reproduce locally.
When I try www.ghost..., I get:
This webpage has a redirect loop
ERR_TOO_MANY_REDIRECTS
Does anybody have any idea what I'm doing wrong? I've lost track of how many different configurations I've tried, but nothing seems to work.
Thanks!
UPDATE
OK, so following the advice in the comment I managed to get the situation a bit better. Still it's counter intuitive for me how the article I initially linked to just didn't get the job done while the other SO question did. So here's what I've changed:
Deleted the www.ghost... alias from OpenShift.
Changed CloudFlare's CNAME record from www -> blabla.rhcloud.com to www -> ghostlessmachine.com
Created this Page Rule: www.ghostlessmachine.com/* -> http://ghostlessmachine.com/$1
Now both ghost... and www.ghost... work and take me to http://ghost.... However, if I type https://ghost..., it also works without redirecting me to simple http. This is a problem.
I tried using this Page Rule instead:
ghostlessmachine.com/ -> http://ghostlessmachine.com/$2
So that I got https://, http://www, www, everything redirected to http://ghost..., but it doesn't work. I can't access my blog anymore and whatever address I try I get ERR_TOO_MANY_REDIRECTS.
UPDATE 2
Here's my full setup after all suggestions:
htaccess:
wp-config.php:
CloufFlare:
Result:
https -> http on non-admin/login pages: WORKING ✓
Trying to access admin/login pages: ERR_TOO_MANY_REDIRECTS
Update 3
This did the trick:
I still don't understand why this works and the rest doesn't though. This was basically a series of rather blind trial and error with some input from Allen here and Simon in the CloudFlare support page. In any case, all my requirements are respected now, thanks!
make sure following in your wp-config.php file:
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
look over here: Force non-WWW but force https across all of wordpress & the entire domain
for redirect everything else to non-https, you can add following into your root .htaccess file, before the wordpress rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/wp-admin.*
RewriteCond %{REQUEST_URI} !^/wp-login.*
RewriteCond %{HTTP_REFERER} !^https://.*
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Update:
CloudFlare's Page rule has following "Page rule priority is determined by their position in the list. If multiple rules match a URL, rules at the top take higher priority. "
let's see what happens before:
request to https://www.ghostlessmachine.com/wp-admin hit the first
rule, match found, then it goes to
http://www.ghostlessmachine.com/wp-admin!
now here comes http://www.ghostlessmachine.com/wp-admin, first rule,
no rewrite, goes down to 3rd rule, oops, it needs goto
https://www.ghostlessmachine.com/wp-admin!
this is how the loop comes
My wordpress site is visited by a lot of spam referrals. I edited the .htaccess file to block some known spam referrals but that is not helping me since there are more and more spams referrals coming. Is there is any standard way to filter out the spam referrals? Please let me know.
Some of the spam websites visiting my blog are:
simple-share-buttons.com
4webmasters.org
free-share-buttons.com
googlsucks.com
theguardlan.com
The .htaccess file can control the access to your website, but this type of spam, commonly called Ghost Referrer Spam, hits directly your analytics and it never accesses your site, so it's pointless to block them from the .htaccess file.
To stop them you should add a filter in your GA. There are many approaches to do it, you can add a filter for every spammer(or stack them in one expression) or you could use a more advanced filter with your valid hostnames. You can check these answers for more information.
https://stackoverflow.com/a/28354319/3197362
https://stackoverflow.com/a/29717606/3197362
If you want to permanently block specific referrals you can do it with .htaccess file. To block referrals that you listed above, you can add this snippet to your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?.*4webmasters\.org.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?.*googlsucks\.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?.*free\-share\-buttons\.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?.*simple\-share\-buttons\.com.*$ [NC]
RewriteRule ^(.*)$ – [F,L]
</IfModule>
List with many more "bad" referrals, you can find here: https://github.com/Stevie-Ray/htaccess-referral-spam-blacklist-block/blob/master/.htaccess
The htaccess method did not work for me but, I was able to remove it from Google Analytics by using filters.
Go to your Google Analytics account and select the Admin tab.
Click on New Filter
Enter 4webmasters.org as a name for the Filter.
Select Filter Type Custom. In Filter Field, find and select Campaign Source. In the Filter Pattern text box, write 4webmasters.org After you set everything Save.
This can take 24 hours for Google to update it.