Site icon Dhanendran's Blog

WordPress: Permalink setting redirecting to 404?

wpwebhost-tutorial

You have installed everything on server apache, WordPress, brand new theme, all plugins… But your permalink setting not working at all? Is it throwing you 404 page? You have set .htaccess file as per WordPress suggestion?

If YES, then consider your problem is solved 🙂

Make sure you have enabled rewrite module on Apache. If not, quickly run the below command to enable it.

sudo a2enmod rewrite
sudo service apache2 restart

Then, You should be placed your .htaccess file in the application root directory with the following code. In my case it is /var/www/html/.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

So, what is these lines and what it does?

Actually, we are trying to overwrite the default Apache .htaccess settings. So, we should tell the apache to allow these overwrites to work.

Open up your apache config file to enable file override.

sudo nano /etc/apache2/apache2.conf

Add the following code to this file.

<Directory /path/to/site>
     #add the following setting to allow .htaccess in your web dir to work
     AllowOverride FileInfo

     #other settings ---

</Directory>

/path/to/site in my case it is /var/www. That’s it. Now restart apache and change your WordPress permalink as per you wish.

sudo service apache2 restart

Cool… Isn’t it…!

Exit mobile version