How to enable mod_rewrite in Apache ?
Posted by: mihai11 (---.Asconet.ro)
Date: November 28, 2006 07:02PM

Hi all,



I installed Apache as part of WAMP package (I am using WAMP 1.6.6). Now I enable mod_rewrite in Apache. I did the following:

1. Uncomment the following line in httpd.conf file:

LoadModule rewrite_module modules/mod_rewrite.so

2. Put a .htaccess file in the root directory:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ super.html

3. Restart Apache

If my understanding is correct, when I type

www.somesite.com/super.html

I should be redirected to

www.somesite.com/index.php

but this doesn't happen. Most probably my mod_rewrite engine is not enabled ? How can I test if it is truly enabled ?



Regards,
Razvan

Options: ReplyQuote
Re: How to enable mod_rewrite in Apache ?
Posted by: Psychopsia (---.unis.edu.gt)
Date: November 28, 2006 09:15PM

To enable Rewritemod on the icon tray just go to "Apache modules" > "rewrite_module".

> RewriteRule ^index\.php$ super.html

Here you are telling to apache that when someone types www.example.com/index.php do a internal redirect to example.com/super.html

So, maybe you want to do the inverse, when someone types example.com/super.html go to www.example.com/index.php

RewriteRule ^super\.html$ index.php [nc]

Hope this helps



Post Edited (11-28-06 23:44)

Options: ReplyQuote
Re: How to enable mod_rewrite in Apache ?
Posted by: mihai11 (---.Asconet.ro)
Date: November 28, 2006 09:39PM

You are right. I already sorted that problem out. Besides that I found out why it was not working smiling smiley

The problem was in httpd.conf file. In order to activate the .htaccess file for a given folder you need to use this directive:

AllowOverride All


Since I have virtual hosts, my httpd.conf file now looks like this:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
ServerName www.xml-forums.net
ServerAlias xml-forums.net
DocumentRoot D:/www-xml-forums.net

LogLevel warn
ServerSignature On

<Directory "D:/www-xml-forums.net">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>


Options: ReplyQuote


Sorry, only registered users may post in this forum.