How do I enable clean URLs with Nginx for Drupal?

March 26, 2015 12k views
LEMP Nginx

I'm using the Lemp, how do I enable clean URLs with Nginx for Drupal?

Thanks for your help

2 Answers

You have to edit your Nginx server configuration file.
It should look like the example below.

server {
     listen       80;
     server_name  example.org;

     location / {
         root   /path/to/drupal;
         index  index.php;
         error_page 404 = @drupal;
     }

     location @drupal {
         rewrite ^(.*)$ /index.php?q=$1 last;
     }
 }

@MatthewTV This worked perfectly for me, thanks!

Have another answer? Share your knowledge.