Get WordPress .htaccess running on Nginx

After several tweaking, I finally found the issue to make the htaccess to run on Nginx. Well, not actually run htaccess since it is for Apache. So for Nginx I have to convert the rewrite from Apache to Nginx.

First by using this online tools http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ to convert the original .htaccess content of mine

 RewriteEngine On 
RewriteBase /blog/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /blog/index.php [L]

to

 #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 /. /blog/index.php last; 
} 
Advertisements