R
R
Resize2017-10-20 15:46:30
Nginx
Resize, 2017-10-20 15:46:30

How to make .htaccess in nginx?

Good day forum users.
I ask for your help.
I need to redirect to nginx. I found the code myself, but could you tell me what file extension in nginx should be done. On Apache .htaccess, but in nginx I don't know what it should be.
And the file itself should be dumped into the root folder of the site?
If it's not difficult, check if the code is correct.
Code:
New Server Block - www to non-www
server {
listen 80;
listen 443 ssl;
server_name www.site.com.ua;
return 301 $scheme://website.com.ua$request_uri;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fixid, 2017-10-20
@Resize

Nginx doesn't understand htaccess and won't.
It is necessary to port your htaccess to the location set with handles / third-party services.
The code does not say anything, in general it will only work for a redirect.

B
borodka_lenina, 2017-10-20
@borodka_lenina

Use allow|deny directly in the config.
The code is incorrect, it seems that you need to describe location / and it already contains a redirect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question