my mod-rewrite does odd things!

Discuss practical ways rearrange URLs using mod_rewrite.

Postby snowball » Sat Sep 15, 2001 3:13 am


I've been trying to use the virtual user hosts feature of mod-rewrite:

I want to make:

find a page which is at

("arnold" is one of loads of different user names - currently just a page under construction)

The best code i've used so far is :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.[^.]$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www.([^.]+)*) /webspace/$1/$2/index.html

which I have placed in a .htaccess file in the directory.

It gives me an error message:


You don't have permission to access


on this server.

Apache/1.3.19 Server at Port 80

Why does it keep repeating - It's almost correct if you take the first bit and the last !

Any help or ideas would be much appreciated.

Posts: 2
Joined: Fri Sep 14, 2001 4:00 pm

Postby Brett » Wed Sep 26, 2001 11:54 am

It looks to me like it will keep repeating because there are no conditions on your second "RewriteRule" statement.

One way to fix this: Add a RewriteCond statement of the form
RewriteCond %{REQUEST_URI} !^/webspace/

Another way: In your webspace directory, include an .htaccess file with the statement RewriteEngine off
Posts: 82
Joined: Tue Jul 10, 2001 4:00 pm

Postby snowball » Sun Sep 30, 2001 1:41 pm

Well thanks Brett .... it worked great (the second method with extra .htaccess file).

Solved it straight away.

Much appreciated.


Posts: 2
Joined: Fri Sep 14, 2001 4:00 pm

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 4 guests