skip to Main Content

Need snippet for nginx config file. Original .htaccess:

Options -MultiViews

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

2

Answers


  1. Nginx doesn’t support .htacess file. You can import your .htacess settings to nginx conf file.

    You can use .htacess to nginx converter https://winginx.com/en/htaccess.

    Login or Signup to reply.
  2. if wordpress site is inside /var/www/html/web/wordpress then nginx config should be

    location ~ ^/web/wordpress/index.php$ { }
    
    location /web/wordpress/ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    if (!-e $request_filename){
        rewrite ^/web/wordpress/(.*)$ /web/wordpress/index.php break;
    }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search