Question

mod_rewrite not working on Apache on Ubuntu 16.04 with self-signed certificate

I have a LAMP stack Droplet on Ubuntu 16.04. I’ve followed the tutorial to setup mod_rewrite here. If I type sudo a2enmod rewrite it indicates Module rewrite already enabled. However, the rewrite rules do not work.

This answer indicates that this might has to do with my VirtualHost *:443 settings, is that so?

Contents of /etc/apache2/sites-available/000-default.conf <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html

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

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

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>

    Redirect permanent "/" "https://188.166.60.249/"

</VirtualHost>

Contents of .htaccess RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Found the solution here.

In /etc/apache2/apache2.conf changed:

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

to

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

Last question is if this does not impose security risks…?

What is in error log ?

/var/log/apache2/error.log