You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ma...@gmail.com on 2012/03/08 23:21:43 UTC

[users@httpd] mod_rewrite confusion

newb question.

I need to redirect everything from www.mysite.com/admin and
mysite.com/admin to admin.mysite.com. Because several boxes share the
same configuration and some of them will serve admin.mysite.com, I
can't use a plain redirect.

This rule to do the redirect, and every variation I've tried, doesn't
ever match:

RewriteCond %{HTTP_HOST}     !^admin\.mysite\.com$ [NC]
RewriteRule  ^/admin                  https://admin.mysite.com [R=301,L]

What am I missing? Any help is greatly appreciated.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite confusion

Posted by Eric Covener <co...@gmail.com>.
On Thu, Mar 8, 2012 at 5:21 PM,  <ma...@gmail.com> wrote:
> newb question.
>
> I need to redirect everything from www.mysite.com/admin and
> mysite.com/admin to admin.mysite.com. Because several boxes share the
> same configuration and some of them will serve admin.mysite.com, I
> can't use a plain redirect.
>
> This rule to do the redirect, and every variation I've tried, doesn't
> ever match:
>
> RewriteCond %{HTTP_HOST}     !^admin\.mysite\.com$ [NC]
> RewriteRule  ^/admin                  https://admin.mysite.com [R=301,L]
>
> What am I missing? Any help is greatly appreciated.
>

If you're in <Directory> or htaccess context, the part of the URL that
lead you to that context, including a trailing slash, is stripped from
the string you're comparing to.

So if this is in the docroot, RewriteRule compares against "admin" not
"/admin" since / is stripped out.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org