httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin <>
Subject [users@httpd] mod_rewrite redirects instead of silent rewrite
Date Tue, 13 Jan 2009 21:45:47 GMT

I hope that you could help me, because I've spent hours on googling and 
reading mod_rewrite docs and still can't get it working...

What I want to achieve as a final effect is that GET requests like

will be internally rewritten and served as

without redirects so URL in user's browser will remain clean, and I will 
avoid one more request. It should give the same effect as typing e.g. in the browser.

Here's my configuration:

Apache is already configured for * like

<VirtualHost *:80>
	ServerAlias *
	DocumentRoot /some/path
# rest of config here

I've tried to add

RewriteEngine On
RewriteCond %{HTTP_HOST} (.+)\.demo\.myapp\.com$
RewriteRule ^/$ /usersite/%1

but the effect is that apache is looking for a file 
/some/path/usersite/lucy instead of rewriting query-string to 
/usersite/lucy (later it is passed to the Ruby on Rails backend using 
mod_passenger, but I've tried to do that without this module and I 
encounter the same problems).

I've tried also to force it to treat this as an URL, not a path by 
passing full URL:

RewriteEngine On
RewriteCond %{HTTP_HOST} (.+)\.demo\.myapp\.com$
RewriteRule ^/$ http://%0/usersite/%1

As log says, it constructs URL in a good way, but it invokes 302 
redirect. In documentation, there's an information that if current host 
matches host in second part of RewriteRule, schema and host got stripped 
and query string is rewritten. It doesn't actually happen.

Any ideas? What am I making wrong? I use apache 2.2.



The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message