You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marcin <ww...@saepia.net> on 2009/01/13 22:45:47 UTC
[users@httpd] mod_rewrite redirects instead of silent rewrite
Hi,
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
http://john.demo.myapp.com/
http://lucy.demo.myapp.com/
will be internally rewritten and served as
http://john.demo.myapp.com/usersite/john
http://lucy.demo.myapp.com/usersite/lucy
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.
http://lucy.demo.myapp.com/usersite/lucy in the browser.
Here's my configuration:
Apache is already configured for *.demo.myapp.com like
<VirtualHost *:80>
ServerName demo.myapp.com
ServerAlias *.demo.myapp.com
DocumentRoot /some/path
# rest of config here
</VirtualHost>
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.
Thanks,
m.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite redirects instead of silent rewrite
Posted by Marcin <ww...@saepia.net>.
Nick Kew pisze:
> Marcin wrote:
>
>> I didn't wanted to do proxy, I wanted just to change e.g. /abc to /xyz
>> and then pass it directly (without proxing) to rails handler.
>
> Sounds like you want the "Alias" directive.
>
I don't think so, because it maps to the filesystem. My URLs are not
real, they don't have any real files at the filesystem. They are handled
by RoR routes mechanism to map them into controllers & actions.
m.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite redirects instead of silent rewrite
Posted by Nick Kew <ni...@webthing.com>.
Marcin wrote:
> I didn't wanted to do proxy, I wanted just to change e.g. /abc to /xyz
> and then pass it directly (without proxing) to rails handler.
Sounds like you want the "Alias" directive.
--
Nick Kew
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite redirects instead of silent rewrite
Posted by Marcin <ww...@saepia.net>.
Krist van Besien pisze:
> On Tue, Jan 13, 2009 at 10:45 PM, Marcin <ww...@saepia.net> wrote:
>
>
>
>> 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.
>
> Add the [P] flag to force proxying...
I didn't wanted to do proxy, I wanted just to change e.g. /abc to /xyz
and then pass it directly (without proxing) to rails handler.
But I hadn't found a solution and I'm proxying that
m.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite redirects instead of silent rewrite
Posted by Krist van Besien <kr...@gmail.com>.
On Tue, Jan 13, 2009 at 10:45 PM, Marcin <ww...@saepia.net> wrote:
> 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.
Add the [P] flag to force proxying...
Krist
--
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite redirects instead of silent rewrite
Posted by Bob Ionescu <bo...@googlemail.com>.
2009/1/13 Marcin <ww...@saepia.net>:
> 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
May be you want to add the [PT] flag?
Bob
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org