Monday, March 2, 2020

WSL 2 Ubuntu 18.04 LTS Wordpress Permalinks not working with htaccess file




Recently setting up Wordpress on LAMP stack on Windows Subsystem for Linux 2 (WSL 2) with Ubuntu 18.04 LTS and as standard procedure to enable permalinks you have to include a Permalink .htaccess in top public_html directory.







.htaccess file 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


However, this did not work. And had to adjust the vhosts conf file :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName yoursite.com

    DocumentRoot /var/www/yoursite.com/public_html
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    
    <Directory /var/www/yoursite.com/public_html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

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

</VirtualHost>

Vhosts file located in 
/etc/apache2/sites-available
Don’t forget to restart apache after editing the conf file:
sudo service apache2 restart

No comments:

Post a Comment