Question

.htaccess doesn't work on ubuntu droplet

I installed LAMP on my droplet and then I followed this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite and I used the contents for the file from my old web hosting, so I know it works: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA]

However, if I enter for example http://cyan.red/index it comes up with: Not Found

The requested URL /index was not found on this server.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart

By default the LAMP install will disable usage of the .htaccess file.

You need to edit the configuration file for your virtual host.

 $ nano /etc/apache2/sites-available/000-default.conf

Change the <VirtualHost> directive to look something like this. The important part is AllowOverride All, as this tells Apache that the directory can override default settings using a .htaccess file.

<VirtualHost *>
     ServerName cyan.red
     ServerAlias www.cyan.red
     DocumentRoot /var/www/html

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now make sure the website is enabled.

  $ a2ensite 000-default.conf

Also make sure that the rewrite mod is enabled.

  $ a2enmod rewrite

Now restart Apache

   $ service apache2 restart