[solved] convert htaccess apache to nginx wordpress rewrite rule

convert htaccess to nginx

convert htaccess apache to nginx

Saya baru migrasi dari apache2 ke nginx. Saya bingung bagaimana rewrite rules untuk wordpress di nginx ?
Berikut ini adalah htaccess saya sebelumnya…

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# END WordPress



  1. open/buka nginx.conf di /etx/nginx/nginx.conf
    vi /etx/nginx/nginx.conf
  2. edit atau tambahkan barus seperti berikut, sesuaikan pathnya
    server {
      location /blog {
          try_files $uri $uri/ /blog/index.php?$args;
      location ~ \.php$ {
          fastcgi_split_path_info ^(/blog)(/.*)$;

    asumsi wordpress punya subdirectory blog

lihat juga cara redirect dengan nginx disini
ada juga tool online untuk konversi disini

About the htaccess to nginx converter winginx.com
The service is to convert an Apache’s .htaccess to nginx configuration instructions. First of all, the service was thought as a mod_rewrite to nginx converter. However, it allows you to convert some other instructions that have reason to be ported from Apache to nginx. Note server instructions (e.g. php_value, etc.) are ignored. The converter does not check syntax, including regular expressions and logic errors. Please, check the result manually before use.

I’m having no luck converting htaccess rules to nginx rewrite. I’ve checked out the NginxRewriteModule documentation and have a few done, but the more complicate ones I’m at a loss for. Here’s what I’m looking at: