nginx and wordpress pretty urls

xsname

Verified User
Joined
Oct 20, 2013
Messages
6
Hello Guys,

I am new to directadmin and also on nginx too. I just compiled nginx using cutombuild script came with directadmin installation on my server. Wordpress configures .htaccess automatically with permalink function but nginx doesn't have .htaccess. I found a tool on internet to convert .htaccess file to nginx rules. I placed converted code into Admin Level --> Custom HTTPD Configurations --> domain.tld --> First Box. My following (default) .htaccess file was converted to 2nd code below;

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

# END WordPress

NGINX Code

Code:
#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;
}

It works like charm but my pretty urls getting /index.php/permalink instead of /permalink

eg; domain.tld/index.php/permalink

How can I get rid from /index.php from url ?

Thank You,
Hassan
 
Back
Top