Enabling pretty permalinks on Wordpress - apache configuration does not work Enabling pretty permalinks on Wordpress - apache configuration does not work wordpress wordpress

Enabling pretty permalinks on Wordpress - apache configuration does not work


Make sure the AllowOverrides directive is set to all in the vhost - that's what tells apache to look for .htaccess files in the webroot.

A better solution is actually to put your rewrite directives in the vhost, as you clearly have write access to the file. When you have AllowOverrides on, apache will look in the directory and all parent directories for .htaccess files on every request, which can be a big performance hit.

For Wordpress, your vhost should look something like:

<VirtualHost *:80>    ServerName example.com    DocumentRoot /var/www/site    <Directory /var/www/site>         Options Indexes FollowSymLinks        AllowOverride None         Order allow,deny         allow from all         RewriteEngine On        RewriteBase /        RewriteRule ^index\.php$ - [L]        RewriteCond %{REQUEST_FILENAME} !-f        RewriteCond %{REQUEST_FILENAME} !-d        RewriteRule . /index.php [L]    </Directory> </VirtualHost>


Solved it myself.

It had to do with the file "000-default.conf" - I copied it to "default" and edited "default", like I already mentioned in my question.

Apparently the service is using the file "000-default.conf" on itself. By copying the "default" file back to "000-default.conf" and restarting the apache service, everything works now.

One caveat: calcinai's suggestion seems like it should work, but with his suggestion in my vhost in the correct "000-default.conf" file, I got a 403 Forbidden error. When I replaced his content with my original content

DocumentRoot /var/www<Directory />        Options FollowSymLinks Indexes        AllowOverride FileInfo</Directory>

And then once again restarting the apache service, it all worked.

Thanks calcinai for your effort to try to help me :)


Permalink Problem

Inside of this file, we want to change all things.

sudo nano /etc/apache2/sites-available/000-default.conf000-default.conf 

- should look something like this:

    ServerAdmin webmaster@localhost    DocumentRoot /var/www/html    <Directory /var/www/html/>        Options Indexes FollowSymLinks        AllowOverride All        Require all granted    </Directory>    ErrorLog ${APACHE_LOG_DIR}/error.log    CustomLog ${APACHE_LOG_DIR}/access.log combined

If you dont see like this then paste the above code inside virtual host

When you are finished, save and close the file.

Next, we need to enable the rewrite module, which allows you to modify URLs. You can do this by typing:

sudo a2enmod rewrite

After you have made these changes, restart Apache:

sudo service apache2 restart