DEV Community 👩‍💻👨‍💻

Sahil kashyap
Sahil kashyap

Posted on

Wordpress Permalink( shows 404) not working in LAMP stack ubuntu 20.04

Assuming

  • php7.4 is running(php8.0 showed way to many error to run wordpress)
  • you've placed your wordpress project in /var/www/html/mywordpress and given it file permission 755(basically read & write in folder/files & subfolder/files)
  • setuped the db connection in wp-config.php properly
  • went to url: "localhost/mywordpress/wp-admin" and allowed the permalinks
  • an automatic .htaccess would have been created or wordpress UI will give you the .htaccess file content. copy it and paste it in "mywordpress" folder

before rewrite

sudo a2enmod rewrite

make sure its enabled

Here's the solution

  1. go to this file
    /etc/apache2/apache2.conf

  2. open it in sudo nano or simply drop the file in vscode
    Go to line "159"

and update this line

<Directory />
    Options FollowSymLinks
    AllowOverride none
    Require all denied
</Directory>
Enter fullscreen mode Exit fullscreen mode

to

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all denied
</Directory>
Enter fullscreen mode Exit fullscreen mode

and
on line 170

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride none
    Require all granted
</Directory>
Enter fullscreen mode Exit fullscreen mode

to

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
Enter fullscreen mode Exit fullscreen mode

now save the file
and in cmd run this

sudo service apache2 restart

this should fix it

Top comments (0)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠