K
K
KASich2020-06-30 13:01:12
Nginx
KASich, 2020-06-30 13:01:12

How to convert a rule from apache to nginx?

Each subdomain has its own robots.txt. Task: when accessing robots.txt, process the request in robots.php, which in turn returns the required robots.txt.

Previously, this rule was processed in .htaccess on apache.

RewriteCond %{REQUEST_FILENAME} robots.txt
RewriteCond %{DOCUMENT_ROOT}/robots.php -f
RewriteRule ^(.*)$ /robots.php [L]

Now everything works under nginx. Please tell me how to make the same rule for him.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Swartalf, 2020-06-30
@Swartalf

You can try online converters like this

D
dodo512, 2020-06-30
@dodo512

rewrite ^/robots\.txt$ /robots.php;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question