Ubuntu – How to enable clean url with Ubuntu 16.04, Drupal 8.1.10 and Apache 2

16.04Apache2drupalmod-rewritephp7

I'm trying to install Drupal 8.1.10 on a virtual private server (OVH) with Ubuntu 16.04, Apache 2 and PHP7. I followed this tutorial :

https://www.howtoforge.com/tutorial/how-to-install-drupal_8-with-apache-and-ssl-on-ubuntu-15-10/

I'm stucked at the requirement level. Drupal tells me that clean url are not enabled. I've added this to both my apache2.conf and my drupal.conf :

<Directory "/var/www/drupal">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted

            RewriteEngine on
                RewriteBase /
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_URI} !=/favicon.ico
                RewriteRule ^ index.php [L]
                </Directory>

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

Still does not work. I've been searching what's wrong for hours but I could not find a solution.

Any help ?
Thanks

Best Answer

Use below process to enable clean url with Ubuntu 16.04:

  1. Enable apache mode rewrite -

    a2enmod rewrite
    
  2. put below code into /etc/apache2/sites-available/000-default.conf

    <Directory /var/www/html>
     Allowoverride All
    </Directory>
    
  3. service apache2 restart

This is working for me...

Related Question