Rewrite htacces form apache to nginx

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]

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

Works decently …


thanks eris and sahsanu that its work :grin:

1 Like