Removing index.php from WordPress URLs with nginx
Since I use nginx and varnish with WordPress (and lighttpd as the webserver), I was interested in using nginx to remove the index.php “directory” that is added to WordPress URLs. Perhaps this can be disabled with a more appropriate WordPress configuration, however since I didn’t want to mess with that, I did it myself. The code is “simple,” however it took a few hours to figure out. if ($uri ~ index.php){ set $redirect_allow 1;}if ($uri !~ ((154)|(admin-ajax.php))){ set $redirect_allow 1$redirect_allow;}if ($redirect_allow = 11){ rewrite ^\/(index.php)\/(.*)$ /$2 redirect;}if ($uri !~ ((!((\/)!(.+))))|(\/index.php\/(.)$)|(\/(wp-admin)(.))|(\/(wp-content)(.))|(\/(wp-login)(.))|(\/(wp-includes)(.*)))# If the URL is not empty, or it doesn’t contain index.php or or doesn’t contain… Read More »Removing index.php from WordPress URLs with nginx