@vinnie
Enabling clean URLs in Drupal is an important step in improving the usability and SEO of your site. Here’s how you can enable it:
For Drupal 7:
For Drupal 8 and Above:
For Nginx:
If you're using Nginx instead of Apache, you’ll need to configure your server block to handle clean URLs. Here’s a basic example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
server { listen 80; server_name yourdomain.com; root /path/to/drupal; index index.php index.html index.htm; location / { try_files $uri /index.php?$query_string; } location ~ '.php$|^/update.php' { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # or whatever php version you're using fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~* .(js|css|png|jpg|jpeg|gif|ico|svg)$ { try_files $uri @rewrite; expires max; log_not_found off; } location @rewrite { rewrite ^/(.*)$ /index.php?q=$1; } } |
Make sure to replace /path/to/drupal
with your actual Drupal installation path and yourdomain.com
with your actual domain.
Testing Clean URLs:To verify that clean URLs are working, try accessing a page on your Drupal site with and without the ?q=
parameter. If both URLs lead to the same page (without redirection), clean URLs are functioning correctly.
Ensure that your server configurations match the requirements for the Drupal version you’re using and contact your hosting provider if you encounter persistent issues.