Centos – Setting up permalinks and mod_rewrite in Apache

centosmod-rewriteWordpress

I migrated WP to a CentOS VM and I'm trying to setup pretty URLs.

My first move is to edit the conf file:

vi /etc/httpd/conf/httpd.conf

Under the appropriate tag:

<Directory "/var/www/html">

And set AllowOverride from None to All:

AllowOverride All

As soon as I change that setting, I get errors on all the admin pages: http://screencast.com/t/ePNCxORe

Not sure if this belongs on the WP forum or some other forum. Thanks in advance.

I should also add that my hostname is the IP address. I'm not sure yet how to change it on a local VM.


This is what my .htaccess file in my DocumentRoot looks like:

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php

# 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]
</IfModule>

# END WordPress

Best Answer

The screenshot you show looks like your server is not parsing the PHP code, but instead is displaying it on the screen. Are you sure PHP is properly setup?

EDIT: As per the answer I found in the comments below, the issue lies with the following line in your .htaccess file:

AddHandler application/x-httpd-php5s .php

You need to comment it or remove it, as it's telling Apache to override the PHP handler for your site with the one you specify, and it probably doesn't exist on your new server.

Related Topic