Quality Work Make Your Dream Come True
WordPress BuddyPress bbPress Developer

How to Avoid WordPress Permalink 404 on Your Apache Server

A friend ask me why all pages on his wordpress site are 404 page not found, after he enabled pretty wordpress permalink structure, I did a quick check and I found he did not enable mod_rewrite on his apache at all, I record fix steps in here:

1: ssh to your server and log in as root, on ubuntu, the command will be

sudo su

2: activate mod_rewrite on your site, on ubuntu, it should be:

sudo a2enmod rewrite

then restart your apache, on ubuntu, this should be:

sudo service apache2 restart

3: Allow edit .htaccess file, wordpress will write all rewrite rules in .htaccess, on ubuntu, you need change the apache config file like this:

sudo nano /etc/apache2/sites-enabled/000-default.conf

ubunThis will open nano edit window, you will find there are line like this:

DocumentRoot /var/www/html

under this line, just add:

<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

then CTRL+O to save and CTRL+x to exit nano.

and restart your apache again:

sudo service apache2 restart

 

4: Go to wordpress admin area and change permalinks to Pretty Permalinks, it means the link structure like:

https://yourdomain.com/?/p=1

will looks like:

https://yourdomain.com/hello-world

It is better to understand and it is better for SEO.

Best Regards,

Tomas

 

Leave a Reply