I am trying to use mod_rewrite
module of Apache24 server
, but I am not being able to load it. I know there have been many questions asked regarding this topic and I have gone through all of them but nothing seem to work. These are the steps that I have followed until now—
-
CHANGED
httpd.conf
file made these changes:
a. UncommentedLoadModule rewrite_module modules/mod_rewrite.so
b. ChangedAllowOverride None
toAllowOverride All
-
Restarted apache server
-
Checked loaded modules using command prompt command
httpd -M
. I can see there that the mod_rewrite module has loaded. I am attaching the image below.
But after performing all these steps I can't see mod_rewrite as loaded module in phpinfo
.
As it can be seen in the above pic there is no mod_rewrite loaded module.
Also as a wild hack I even tried rewriting URLs using .htaccess
file but this is not working. Apache seems to ignore .htaccess
file although I have put that file inside my root directory.
Note: I am running `PHP` as an apache module
Using `WAMP` stack
Using `localhost` as server
I need this module badly for URL rewriting purposes. Can you guys suggest some other way to load this module?
EDIT
I have tried to rewrite URL from virtual host as the answer suggests that the module is loaded and it does not depend neither on .htaccess
nor on info.php
.But stil it is not redirecting. I am adding the Virtual host
setup below—
<VirtualHost *:80>
<Directory "/Apache24/htdocs">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
</Directory>
ServerName localhost
DocumentRoot "/Apache24/htdocs"
ErrorLog "/Apache24/logs/error.log"
CustomLog "/Apache24/logs/access.log" combined
<directory "/Apache24/htdocs">
<IfModule rewrite_module>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule rewrite_module>
RewriteRule ^working.php fun.html
</IfModule>
</directory>
# Rewrite Rules #####################
RewriteEngine On
RewriteRule ^working.php fun.html
# end Rewrite Rules #################
</VirtualHost>
The above code does not redirect it to working.php
when I try to run fun.html
. It simply says:
the requested URL /working.php was not found on this server.
Best Answer
Aside from Loading the module the only directive you need is:
RewriteEngine on
Extra: