TransWikia.com

Updating httpd.conf not working for permalinks

Stack Overflow Asked by sotn on December 28, 2020

I am unable to set permalinks to end with post names. I receive a 404 error. The closest I got is to set custom permalink to:

/index.php/%postname%

But this causes ‘index.php’ to show up in the URL. I also updated my httpd.conf to set the root dir to:

AllowOverride All

But it still does not work. My wordpress is hosted on AWS EC2 linux AMI.

One Answer

Activate the mod_rewrite module with

sudo a2enmod rewrite

and restart the apache

sudo service apache2 restart

To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with

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

Below “DocumentRoot /var/www/html” add the following lines:

<Directory “/var/www/html”>
AllowOverride All
</Directory>

Restart the server again:

sudo service apache2 restart

EDIT:

Found my htaccess file was missing. So followed the steps listed here :

https://wordpress.org/support/article/using-permalinks/#wheres-my-htaccess-file

  • Created htaccess in wp root which, on my server, was /var/www/html.
  • Added the required rewrite rules provided in the link above.
  • Set chmod on htaccess to 775
  • Set chown on htaccess to apache:apache
  • Restarted httpd service

Postname permalink now works!

Correct answer by Kishor Patidar on December 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP