How to see if Mod_Rewrite is enabled on the server?
The mod_rewrite Apache module is one of a webmaster’s most valuable tools, allowing her to manipulate URLs in countless ways. A mod_rewrite can be complex because of the many functions it offers. But if you know precisely what kind of URL manipulation you need, it can be as easy as copying and pasting the correct code. Its functions include redirecting website visitors to a different domain and protecting your site’s images from webmasters who are linking to them.
If you are questioning if Mod_Rewrite is enabled on the machine, there are several ways to check if its working, I will try to show you the simplest method,
- Log on to cPanel. Click on “File Manager.”
- Create a .htaccess file (a text file named .htaccess) with the following code in
- Save the file to a subdirectory of your main site something like this/testfolder-rewrite/.htaccess
Now attempt to browse to the subdirectory (http://www.domain.com/testfolder-rewrite/). One of two things could happen
– No errors Congrats mod_rewrite engine is now enabled.
– 500, Internal Server Error If you get this message then mod_rewrite was not installed/enabled on your computer.
In summary, mod_rewrite needs to be enabled on your server to use .htaccess configurations, such as redirects.
You can also Confirming mod_rewrite is enabled on the server through command line
Due to the overwhelming majority of websites requiring mod_rewrite, it’s enabled by default. To confirm it’s enabled you can perform the following:
1. Log into your server as root via SSH terminal.
2. Query apache for currently installed modules, and search for ‘rewrite’.
httpd -l | grep rewrite
root@testserver [~]# httpd -l | grep rewrite
If you see ‘mod_rewrite.c’ returned, you’ve now confirmed it’s installed and enabled properly on your server.
That’s it. Hope this will help you 🙂