Rewrite htacces form apache to nginx

Hello
previously I used the web with apache htaccess…
how to change it so it can be used in nginx hestiacp?
below is my htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^robots.txt _robots.php [L]
RewriteRule ^sitemap-post.xml _sitemap.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

That .htaccess file would translate to something like this:

location /robots {
  rewrite ^/robots.txt /_robots.php break;
}

location /sitemap {
  rewrite ^/sitemap-post.xml /_sitemap.php break;
}

location / {
   try_files $uri $uri/ /index.php?$args;
}

You should create your own nginx template and assign that template to your site.

1 Like

https://winginx.com/en/htaccess

Works decently …

3 Likes

thanks eris and sahsanu that its work :grin:

1 Like