Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
397 views
in Q2A Core by

I am trying to add an Adblock detector to my website. I am using the suggestions that I found here. As it was recommended, I created ads.js file in the document root of my website. This file is accessible only from the root webpage, e.g. https://mywebsite.com/ads.js

But any pages on my website simply don't see it. 

2020/04/10 21:50:01 [error] 10312#10312: *3053530 open() "/var/www/website/tag/ads.js" failed (2: No such file or directory), client: 98.33.30.36, server: website.com, request: "GET /tag/ads.js HTTP/1.1", host: "website.com", referrer: "https://website.com/tag/nginx"

2020/04/10 21:47:21 [error] 10312#10312: *3053478 open() "/var/www/website/1466/ads.js" failed (2: No such file or directory), client: 88.155.169.198, server: website.com, request: "GET /1466/ads.js HTTP/1.1", host: "website.com", referrer: "https://website.com/1466/linux-dlya-slabyx-kompyuterov-i-noutbukov"

Any ideas on how to fix that?

Q2A version: 1.8.2

1 Answer

0 votes
by

I think you did it wrongly.

First, the JS file is located as  yourwebsite.com/ads.js, but the code shows something different

/var/www/website/tag/ads.js   . If the JS is in your root directory, you use it in the code something like this

src="../ads.js"

or you can use the absolute location: src="https://yourwebsite.com/ads.js"

...