[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: mod_rewrite : the weapon of mass-destruction.

The first item of the rewrite command cannot include a hostname in it, only the location on the host and name of the object they're asking for.

You need to use a RewriteCond clause before the RewriteRule to check the host name.

Refer to http://httpd.apache.org/docs/mod/mod_rewrite.html

RewriteCond %{HTTP_HOST} anotherdomain\.ext$
RewriteRule /.* /site2.html [L]

And try putting the

RewriteEngine On
RewriteLog /var/log/apache/rewrite.log
RewriteLogLevel 9

within the virtualhost container.

On Thursday, June 19, 2003, at 05:42  AM, Gavin Hamill wrote:

Hi :)

I've been trying to learn mod_rewrite to do /anything/ and I'm failing. Please
take pity on me, oh mighty ones ! ;)

I wanted to use mod_rewrite as a technology test, and to learn something new, but it has simply driven me to distraction... perhaps someone could help?

I have a woody box (installed yesterday) with vanilla Apache, and a customer who has three domain names, and hundreds of files in /www/maindomain.ext. They also own anotherdomain.ext and thirddomain.ext, and each domain has a
seperate defaultindex page - site1.html, site2.html, site3.html.

What I want to do is use mod_rewrite to check the entire URI they requested,
and "if  http://www.anotherdomain.ext/ or http://anotherdomain.ext is
requested, then display site2.html" and so on for the third site.

Aside from

LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so
RewriteEngine On
RewriteLog /var/log/apache/rewrite.log
RewriteLogLevel 9

I have this:

 DocumentRoot /www/maindomain.ext
 ServerName maindomain.ext
 ServerAlias www.maindomain.ext.
 ServerAlias anotherdomain.ext
 ServerAlias www.anotherdomain.ext
 ServerAlias thirddomain.ext
 ServerAlias www.thirddomain.ext
 RewriteRule anotherdomain\.ext\/$ /site2.html
 RewriteRule thirdomain\.ext\/$ /site3.html

This is just not doing it for me, and I see nothing in the log file (0 bytes, same permissions/owner as the other access.log/error.log which work fine)

In fact, even doing something simple like

RewriteRule ^/gdh.* http://www.google.com/

doesn't have the desired effect :/

I'd be very grateful for any suggestions!


To UNSUBSCRIBE, email to debian-isp-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: