Enable and Configure mod_rewrite for Apache on CentOS 7

The mod_rewrite module is enabled by default on CentOS 7. If you find it is not enabled on your server, you can enable it by editing 00-base.conf file located in /etc/httpd/conf.modules.d/ directory.

Add or uncomment the following line:

Save and close the file, then restart the httpd service:

Once the mod_rewrite module has been activated, you can set up your URL rewrites by creating an .htaccess file in your default document root directory. A .htaccess file allows us to modify our rewrite rules without accessing server configuration files. For this reason, .htaccess is critical to your web server. Before we begin, we need to allow Apache to read .htaccess files located under the /var/www/html directory.

You can do this by editing httpd.conf file:

Find the section and change AllowOverride None to AllowOverride All.

Save and exit.

Now restart Apache to put the change into effect:

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Helwie Ahmad
Helwie Ahmad
2 years ago

thanks for the great tutorial. you save me. i spen 3d for fix my error server 😀

DMCA.com Protection Status
1
0
Would love your thoughts, please comment.x
()
x