https preventing google adsense ads from showing? - .htaccess

Ok, so recently i setup an SSL on my website, and when i visit my website via https:// the ads on my site (served via adsense) won't load.... But if i re-visit my site using http:// the ads start appearing again.. Could this possibly be caused by my .htaccess file? Here take a look
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
ErrorDocument 404 /404.html
Options -Indexes
This is leaving me quite perplexed, any help would be appreciated

I think you are having problem of malicious script which was blocked in https scheme
please refer
https://support.google.com/chrome/answer/1342714?hl=en
How to disable google chrome blocking scripts over https?
https://support.google.com/adsense/answer/1208336?hl=en

Related

How to show a content of one website in another website?

I have a website for example: https://test1.com, and a page on that website https://test1.com/show-content.
I want that page to display the content from another website, for example https://test2.com/show-different-content.
I know I can do it with PHP and file_get_contents, but I'm trying to do it with .htaccess, since I understand it can be possible. I've looked through all the SO questions I found regarding that, but I found no clear solution.
What I have tried in .htaccess is the following:
<IfModule mod_rewrite.c>=
RewriteEngine On
RewriteRule ^show-content$ https://test2.com/show-different-content [P]
</IfModule>
What am I doing wrong? Or am trying to do something that is not possible?
You have two options for this if the owner of that second site actually grants permission to proxy his sites content. You can use the proxy module available for the apache http server.
Either direct:
ProxyPass /show-content/ https://test2.com/show-different-content/
ProxyPassReverse /show-content/ https://test2.com/show-different-content/
Or embedded in the rewriting module:
RewriteEngine On
RewriteRule ^/?show-content/(.*)$ https://test2.com/show-different-content/$1 [P]
Obviously the proxy module needs to be loaded and activated inside the http server.

Server responds with a 403 error after browser update

I have a site that plays music. The user can listen to a song only by navigating to a specific site on the server that retrieves the music file and presents it to the user through the audio html tag. In order to prevent the users from accessing directly the song's address I implemented a year ago the following htaccess script:
Header set Access-Control-Allow-Origin "http://myexamplesite.000webhostapp.com/"
ErrorDocument 403 /error404.php
ErrorDocument 404 /error404.php
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(myexamplesite\.)?000webhostapp [NC]
RewriteCond %{HTTP_REFERER} !^http://(myexamplesite\.)?000webhostapp.*$ [NC]
RewriteRule \.(mp3|png|jpg)$ - [F]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?(myexamplesite.000webhostapp.com)(/)?.*$ [NC]
RewriteRule .*.(.zip|.rar|.exe|.mp3|.pdf|.swf|.psd)$ http://myexamplesite.000webhostapp.com/error404.php [R,NC]
This script has been working flawlessly until a week ago, when chrome and mozilla updated and since then I see the error below on the chrome developer tools.
The browser cannot load any media such as images, documents and music files as described in the script above.
When I remove the script the problem is resolved but by doing so lets the users access and hotlink my resources with great ease.
The most confusing part is that mobile browsers have not any problem while desktop ones show errors. For example the updated chrome and firefox mobile browsers can access the site normally with all those resources without the issues dealt on desktop browsers.
I have tested if the problem appears in various computers and it still appears.
I believe that the problem shows up in newly updated browsers because the problem does not show up on elder versions of mozilla firefox desktop browser (version 47).
What causes this problem? How can I deal with it? I need a solution that does not override the main purpose of the htaccess script; to not allow direct access and hotlinking to sensitive media (images, pdf documents and mp3 files).

htaccess works with www.example.com but not example.com

I have installed Ghost, which needs nodejs to run. I'm doing this on an Apache Linux server via managed hosting. They kindly let me login with SSH access so I've been able to setup nodejs and Ghost using the standard installation instructions. I installed ghost to the root of my domain so in normal operation someone would go to example.com and it'll show them my blog. Well that's what I'd hoped.
However now when I've come to load Ghost in my browser I discover because I'm accessing it the way I am, and that Ghost doesn't do server configuration, I seem to need an htaccess file to be able to make the site reachable.
So, I have created this htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ http://127.0.0.1:65515/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:65515/$1 [P,L]
</IfModule>
With that saved to the root, if I go to example.com/ghost (the admin panel for Ghost) it works. Nothing wrong there, looks great. If however I try and visit the root, ie goto example.com, instead of showing me the index, it shows me index.js - that is, it literally loads the contents of Ghost's index.js file and displays it instead of parsing it and displaying the main index of the website.
IF however I go to www.example.com then it all works. So whatever the problem is it's because I'm not using www. in the domain.
I would prefer it to work both with or without the www in the URL though. I did try adding some solutions to redirect non-www requests to www.example.com to th ehtaccess but for some reason it still doesn't work (as in if I type example.com it doesn't redirect me to www.example.com).
I think maybe you should be using mod_proxy rather than mod_rewrite. At least, that's what I've used in the past. Apache will catch requests coming in on port 80 and then redirect them to port 65515 where your node server is listening.
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
Like this:
ProxyPass / http://localhost:65515/
I figured it out. Wasn't anything to do with htaccess, or Ghost or nodejs or anything like it. No, instead the problem was the sodding server was caching the website. I discovered the setting to delete the cache and it all started working fine, so, this is now solved.

HTTPS to HTTP redirect not working HTTPS loading different websites data

I've got a strange problem with https not redirecting to http. I need https://indudlgeinbrighton.co.uk to redirect to http://indulgeinbrighton.co.uk It's on a shared server and I'm getting a strange cross over with the https. When https is put in, it's loading information for a completely different website hosted on the server.
https://indulgeinbrighton.co.uk is the URL affected. I don't normally share the URLs I'm working on, but in the case I think it might be helpful to see what's going on. Where it's showing data for a website called Churchill, obviously this is a bit of a problem. I've tried putting in all the solutions provided on this page How do you redirect HTTPS to HTTP? into the root .htaccess but it's not working. The htaccess is working fine, because when I switched it to load the other way from http to https it worked fine.
I can only assume it's reading the htaccess file from the other site when it's looking at the https version. As I know which site it is, that's easy enough to locate, but what could I put in that htaccess file to redirect this particular url query without affecting https redirects on the other site?
Thank you.
try this in your .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://indulgeinbrighton.co.uk/$1 [R,L]
this is for security measure
The page at 'https://indulgeinbrighton.co.uk/' was loaded over HTTPS,
but requested an insecure script
'http://churchillbrighton.com/wp-content/themes/brighton-hotels/js/avia.js?ver=3'.
This request has been blocked; the content must be served over HTTPS.
you can try to do this in PHP
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
or include always external files in https

Chrome won't redirect through htaccess

I want to redirect all urls without www to the www-version:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]
that works for every browser except google chrome with subfolders. That means http://domain.tld is redirected to http://www.domain.tld like it should but when I want to access http://domain.tld/subfolder I get a 'ERR_NAME_NOT_RESOLVED' error in chrome.
Firefox, IE, Safari are working.
I have no definite answer for you, but these few hint may help you :
idea 1
Chrome uses google own's DNS, so it might be that it is trying to reach directly the ip host known as www.domain.tld for wich it does'nt find a record.
Idea 2
You might want to install fiddler and run a trace to see exactly what is exchanged between chrome and the internet. This way you'll know if your apache conf is firing the redirect correctly.
I tried typing both adresses in chrome directly : none is recognized by the omnibar (which suggests to me an issue with google dns mirrors)

Resources