0

I need to enable mod_rewrite on a Apache server version 2.4.16. The server is running CENTOS 6.7 x86_64 - I tried many different things but nothing worked.

Also, is there anyway I can find out if mod_rewrite is already enabled?

Thanks, Richard.

3 Answers 3

1

A good way to see if it's enabled is by trying to use it.

The apache documentation shows a pretty simple way to test out mod_rewrite . Place the following in an htaccess file:

Redirect "/foo.html" "/bar.html"

And then check if yoursite.com/foo.html redirects properly.

https://httpd.apache.org/docs/2.4/rewrite/remapping.html

a2ensite is not going to work, that's a binary built into the apache package for debian, you mentioned a centos installation.

To determine specifically if mod_rewrite is built into your apache install, use httpd -M To list loaded modules and grep for the one you want (rewrite).

[root@server ~]# /usr/sbin/httpd -M | grep rewrite
rewrite_module (shared)
[root@server ~]# 
0

Test 1: Easiest way to test if mod_rewrite is ON/OFF is to create a php info file

Under “apache2handler” check for “Loaded Modules” section. There will be a list of loaded modules. Check if mod_rewrite is present in the list.

Test 2: By creating a file called .htaccess and then by typing the following lines in it

Options +FollowSymLinks RewriteEngine On

How to find if mod_rewrite is enabled in Apache server?

0

Try with the command:

sudo a2enmod mod_rewrite
1
  • I tried that before it didn't work. I tried it again just now and I get the following error "Command not found". Commented Oct 18, 2015 at 17:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.