How to write WordPress .htaccess for nginx

I’m trying to change the way pagination looks like:

 example/%year%-%monthnum%-%day%_%post_id%.html

For this purpose in .htaccess I was using this rule:

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

But I don’t understand how to do it in nginx, I tried this:

#ignored: "-" thing used or unknown variable in regex/rew 
if (!-f $request_filename){
        set $rule_1 1$rule_1;
}
if (!-d $request_filename){
        set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
        rewrite /. /index.php last;
}

But when I try to do this ,the login page doesn’t work, and results in an error ERR_TOO_MANY_REDIRECTS.

Read more here: How to write WordPress .htaccess for nginx

Leave a Reply

Your email address will not be published. Required fields are marked *