Richard Rodgers
Richard Rodgers

Reputation: 625

How to enable mod_rewrite on Apache server

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.

Upvotes: 0

Views: 2605

Answers (3)

Spearson
Spearson

Reputation: 61

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 ~]# 

Upvotes: 1

michelem
michelem

Reputation: 14590

Try with the command:

sudo a2enmod mod_rewrite

Upvotes: 0

Lucky Chingi
Lucky Chingi

Reputation: 2258

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?

Upvotes: 0

Related Questions