6

I have been working on a website on an ubuntu server (amazone) and I get 404s entering pages.

I'll give all the information I can regarding the problem.

On WordPress

enter image description here

enter image description here

Refresh page:

enter image description here

I followed this tutorial:

https://wordpress.org/support/topic/solved-permalinks-working-in-apache2-ubuntu-1010?replies=6

And nothing helped.

I found this post https://wordpress.org/support/topic/permalink-does-not-work-apart-from-default?replies=12 - so I entered I entered the file: /etc/apache2/sites-enabled/000-default.conf

and didn't find AllowOverride None to change to AllowOverride All So I added it myself here: enter image description here

Restarted apache, and I got an error. I refreshed the website, and found out it's not working..

Undo AllowOverride All from 000-default.conf

What is the solution for this? I have never worked with Linux servers, so I'll need a very clear and well explained answer please.

BTW, This is what WP generates in my .htaccess file:

# 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
2

2 Answers 2

15

Open a terminal and type:

sudo gedit /etc/apache2/apache2.conf

Find this:

<Directory /var/www/>

Change AllowOverride None to AllowOverride All

Then run:

sudo a2enmod rewrite

Dont forget to restart apache2:

sudo service apache2 restart
2
  • 1
    After days of research, this solved my problem. Thanks!
    – Ege Sucu
    Feb 2, 2020 at 13:08
  • Thank you for this answer - it saved me lots of nerves and time
    – Sharpey
    Nov 14, 2021 at 16:18
0

You can check if there exist an htaccess file in your WordPress home directory as shown above. If it is not there create one:

$ sudo nano /var/www/html/.htaccess

and copy paste the below to it

# 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

Press ctrl+x and press y to save the file. And restart apache by

$ sudo service apache2 restart

You would want to tell apache to follow your .htaccess file. You can do this by editing the apache.conf file

$sudo nano /etc/apache2/apache.conf

Scroll down to the line By default it will be:

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

change the value of AllowOverride to All so now it becomes:

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

Press ctrl+x and press y to save the configuration file. In order to make this changes to server first enable the mod_rewrite by.

$ sudo a2enmod rewrite

And then restart the server

$ sudo service apache2 restart

Done!

Source: https://www.wst.space/riddling-with-wordpress-permalink-setup-issues/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .