If I understand correctly, I need to put something in httpd.config
to enable mod_rewrite. If this is true, what do I need to put in httpd.conf
or apache.conf
? Please be OS specific.

- 15,363
- 26
- 117
- 213

- 4,820
- 21
- 62
- 92
-
Check the answer by @FarmerGedden http://stackoverflow.com/a/16814691/4061061 – captainblack Nov 30 '16 at 15:00
8 Answers
Nope, mod_rewrite
is an Apache module and has nothing to do with PHP.
To activate the module, the following line in httpd.conf
needs to be active:
LoadModule rewrite_module modules/mod_rewrite.so
to see whether it is already active, try putting a .htaccess
file into a web directory containing the line
RewriteEngine on
if this works without throwing a 500 internal server error, and the .htaccess
file gets parsed, URL rewriting works.

- 442,112
- 142
- 972
- 1,088
-
-
2@John you usually can't activate mod_rewrite yourself on shared hosting: It's up to the hosting company to do so. Try `RewriteEngine` to see whether it maybe already is active - if it isn't, you're going to have to talk to them. – Pekka Jun 28 '10 at 09:54
-
@John re your updated comment: Write something like `asdfasdf` into the file. That should land you a `500 internal server error`. – Pekka Jun 28 '10 at 09:55
-
Yeah, okay. It is getting parsed. I still can get even a simple ReWrite to work, though. – John Jun 28 '10 at 10:03
-
@John does it accept `RewriteEngine On` without errors? If it does, the problem is with your rewrite statement. Maybe worth a new question. – Pekka Jun 28 '10 at 10:04
Just a fyi for people enabling mod_rewrite on Debian with Apache2:
To check whether mod_rewrite is enabled:
Look in mods_enabled for a link to the module by running
ls /etc/apache2/mods-enabled | grep rewrite
If this outputs rewrite.load
then the module is enabled. (Note: your path to apache2 may not be /etc/, though it's likely to be.)
To enable mod_rewrite if it's not already:
Enable the module (essentially creates the link we were looking for above):
a2enmod rewrite
Reload all apache config files:
service apache2 restart

- 1,162
- 10
- 23
-
2Exactly what I needed when troubleshooting a permalink Wordpress issue. Thanks for specific SSH commands I needed. – Art Geigel Sep 08 '14 at 03:50
-
In my case, issue was occured even after all these configurations have done (@Pekka has mentioned changes in httpd.conf & .htaccess files). It was resolved only after I add
<Directory "project/path">
Order allow,deny
Allow from all
AllowOverride All
</Directory>
to virtual host configuration in vhost file
Edit on 29/09/2017 (For Apache 2.4 <) Refer this answer
<VirtualHost dropbox.local:80>
DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
ServerName dropbox.local
ErrorLog "logs/dropbox.local-error.log"
CustomLog "logs/dropbox.local-access.log" combined
<Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
# --New way of doing it
Require all granted
</Directory>

- 3,010
- 35
- 36
-
the update seems to be missing the part I needed `AllowOverride All` – CrandellWS Dec 29 '22 at 20:29
No, you should not need to. mod_rewrite
is an Apache module. It has nothing to do with php.ini
.

- 30,738
- 21
- 105
- 131

- 18,537
- 4
- 61
- 64
if it related to hosting site then ask to your hosting or if you want to enable it in local machine then check this youtube step by step tutorial related to enabling rewrite module in wamp apache
https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option
it should be checked but after that wamp require restart all services

- 6,326
- 1
- 39
- 37
network solutions offers the advice to put a php.ini in the cgi-bin to enable mod_rewrite
-
I've heard this, too, but I think it's false. I recommend just checking the syntax of your .htaccess file to screen out any errors. Pretty much any server, including Netsol's, that run Apache have mod_rewrite enabled by default. – goddogsrunning Apr 05 '13 at 20:45
Module rewrite_module is built-in in to the server most cases
Use .htaccess
Use the Mod Rewrite Generator at http://www.generateit.net/mod-rewrite/

- 136,852
- 53
- 295
- 323
-
1This answer is not clarifying. If OP is asking how to enable something, you're expected to assume it's disabled. – Gui Imamura Jul 16 '15 at 18:33