Allow mod_rewrite in CentOS 7

Reading Time: < 1 minute

Today, let us learn how to allow mod_rewrite in CentOS 7. My problem was, I cannot get the mod_write work on my WordPress .htaccess on my Virtual Machine.

What is mod_rewrite?

an Apache module, uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly.

By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL or to invoke an internal proxy fetch.

Here are the .htaccesss rules below:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress

After 2 hours of research, I found out I need to update the AllowOverride from None to All instead. To do so, run the command below:

nano /etc/httpd/conf/httpd.conf

In my current setup, I have my serve files in default location in CentOS 7.

/var/www/html

With that said, just update AllowOverride as shown below:

image-71 Allow mod_rewrite in CentOS 7

Make sure to restart your Apache service by running the command below:

systemctl restart httpd

From here, you should be all set. Great job.

Source 
stackoverflow.com/questions/7337724/how-to-check-whether-mod-rewrite-is-enable-on-server

httpd.apache.org/docs/current/mod/mod_rewrite.html

Was this post helpful?

Leave a Reply