2
votes

I have an Apache 2.2 running on a windows machine.

I am trying to add some URL rewrite directives, and begun with the simplest sanity - rewrite every URL to http://www.facebook.com .

At httpd.conf, I've added the following:

LoadModule rewrite_module modules/mod_rewrite.so

and later in the file, the following:

RewriteEngine on

RewriteRule ^(.*)$ http://www.facebook.com [R]

Redirection doesn't take place at all: when I access existing files, I get them. When I access non-existing addresses, I get the server's 404 page.

I attempted more complex rewrites, with the same result.

What might be the problem? Are there any log files I should check for hints regarding the redirection failure? Thanks!

2
The '#' is a comment character. So you haven't done anything. - Paul Tomblin
My bad - question refers to non-commented directives, of course. - Hatchmaster
Where exactly are you putting the directive? Is it inside a VirtualHost block? - Pekka
Add a RewriteLog and a RewriteLogLevel directive and then look at the log info - Matteo
Pekka - the rewrite directives are not within a VirtualHost. I tried both to put it outside any blocks (i.e. the final lines of the file) and within a directory block. (<Directory "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\main">... </directory>) - Hatchmaster

2 Answers

1
votes

You have to put AllowOveride All in your VirtualHost section

<Directory /path/to/your/www/>
    AllowOveride All
</Directory>
0
votes

you have to put your rewrite rules within a virtual hosts block

<VirtualHost lan-ip:80>

ServerName mysite.com
ServerAdmin [email protected]
DocumentRoot /path/to/site

RewriteEngine on
RewriteRule ^(.*)$ http://www.facebook.com [R]

</VirtualHost>

where lan-ip could be localhost, or more likely, a dedicated ip to serve mysite.com. For local devel you can alias your NIC as say, 192.168.1.101, and modify /etc/hosts (on Linux), like so:

192.168.1.101 mysite.com

Then in your browser you can go to mysite.com and test against local test instance.