D
D
Dextor232019-09-14 13:16:09
htaccess
Dextor23, 2019-09-14 13:16:09

How to create such a condition in .htaccess?

Hello. Tell me please.
How to do this, if I enter site.ru into the browser line, then I get the "blank page / white screen" page on a blank sheet of paper without dops in the domain, for example: (like page.html, etc)
If I go to the same site. ru from the search, then the site opens for me in full.
Or If I go to the same site.ru from the search, then a site with a subdomain 123.site.ru opens for me
At the same time, allow all search bots to see the main page (instead of a white sheet / screen)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-09-14
@Dextor23

An empty page can be formatted as a separate file or put the content directly into the ErrorDocument .
Search bots can be searched by the From or User-Agent HTTP headers.

ErrorDocument 403 "<!DOCTYPE html><html><head></head><body></body></html>"

RewriteEngine on

RewriteCond %{http_Referer} !^https?://(www\.)?(site\.ru|(yandex|google)\.\w+)/
RewriteCond %{http:From}    !(googlebot|yandex)
RewriteRule ^ - [R=403,L]

Put at the beginning of the .htaccess file so that these rules are executed before the rest of the RewriteRule.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question