Question

How do I enable clean URLs with Nginx for Drupal?

Posted March 26, 2015 19.4k views
Nginx LEMP

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

Thanks for your help

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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!

Submit an Answer