Wordpress Permalinks - CentoOS 7

Posted July 12, 2015 16.3k views
ApacheWordPressLAMP Stack

Hi All,

I can’t seem to have permalinks working on my CentOS 7 environment.

I have already created a .htaccess and I can see the Load Module commands done by Wordpress. I also have Mod_rewrite installed already.

Additionally, I have changed the AllowOverride from None to All under <Directory "/var/www/html">

I have also followed the Getting Started Series guide and the LAMP Stack Guide here.

Any thoughts?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers

After much research, I found the solution:

  1. sudo vi /etc/httpd/conf/httpd.conf
  2. Type this in /AllowOverride
  3. Find the second one with <Directory “/var/www”>
  4. Underneath that write the following code:
<Directory "/var/www/">
    AllowOverride All

Thank you @CrypticDesigns for helping out too! Much appreciated.

  • Thank you @josefarrugia.

    A reminder: after making this change, you may have to restart your Apache service before your permalinks will work properly. This was the case for me.

  • Thank You… I am Using a Centos 7, LEMP Server with httpd and This Answer worked like a charm for me after 3 days of struggling.

    Also reinstall httpd sudo yum reinstall httpd before you try this.

If you would like us to help you, please post the content of your .htaccess file here. What kind of permissions does the .htaccess have? Wordpress should be able to rewrite it if needed.

  • Permissions: 664

    # 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]
    # END WordPress

    The .htaccess file is located at /var/www/

Allright looks good to me, what you could try is to delete this .htaccess , then create a new one , keep it empty , chown it to your webserver and chmod it to 664.
Then in wordpress try to switch the permsalink option twice, and check the content of .htaccesss. Then if the content automatically created looks good, restart apache.

The webserver (apache in this case) needs to own the files of the website in the folder to be able to edit them.

So when you delete the .htaccess file, create a new empty one and let the apache server generate its .htaccess input you are sure its the right one. First let the apache server own the directory, execute

sudo chown -R www-data:www-data /var/www/

Afterwards chmod the .htaccess file and then wordpress should be able to generate its .htaccess when you change the options in the backend.

  • Tried your instructions, however, it’s still not working.

    Your command isn’t working. I had to replace the www-data with $USER

    sudo chown -R www-data:www-data /var/www/

    What am I missing?

Oh..I thought you did this already in the first post of your question. My bad, could have told you this earlier. Anayway good you got it solved, if you have any more questions you can come here again.