简体   繁体   中英

Updating httpd.conf not working for permalinks

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM