You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chris Arnold <ca...@electrichendrix.com> on 2013/04/16 00:57:13 UTC
[users@httpd] Rewrite Rule Rewriting root site
We have a server at http://rootsite.net. We also have another site/app that runs at http://apps.rootsite.net. We host client applications on our server using apache so the above site/app needs to be http://apps.ourclientsdomain.tld. Here is what i have gotten to work in the site/app virtual host file:
ServerName apps.*
RewriteEngine On
RewriteCond %{HTTP_HOST} ^apps\.
RedirectMatch ^/$ /somealias/
This appears to work, however, it has also taken over our root site. So http://rootsite.net now takes you to http://rootsite/somealias. How can i stop this from happening? I assume i have something amiss in the above rewrite?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Chris Arnold <ca...@electrichendrix.com>.
On Apr 15, 2013, at 7:51 PM, "Chris Arnold" <ca...@electrichendrix.com> wrote:
> On Apr 15, 2013, at 7:41 PM, "Daniel Ruggeri" wrote:
>
> > On 4/15/2013 6:34 PM, Chris Arnold wrote:
> >> Actually, it is the RedirectMatch specifically causing the problem. How to specify only match http://apps.somesite.tld?
> >
> > You can't. You have to use RewriteCond (as you have) and then use
> > "RewriteRule ^/$ /somealias/" in place of the RedirectMatch that you posted.
>
> I did as you suggested and while http://rootsite.net works, http://apps.rootsite.net does not.
Any ideas on how to make this work? Trying to get apache to catch http://apps.clientdomain.tld and rewrite to http://apps.clientdomain.tld/alias
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Chris Arnold <ca...@electrichendrix.com>.
On Apr 15, 2013, at 7:41 PM, "Daniel Ruggeri" <DR...@primary.net> wrote:
> On 4/15/2013 6:34 PM, Chris Arnold wrote:
>> Actually, it is the RedirectMatch specifically causing the problem. How to specify only match http://apps.somesite.tld?
>
> You can't. You have to use RewriteCond (as you have) and then use
> "RewriteRule ^/$ /somealias/" in place of the RedirectMatch that you posted.
I did as you suggested and while http://rootsite.net works, http://apps.rootsite.net does not.
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Daniel Ruggeri <DR...@primary.net>.
On 4/15/2013 6:34 PM, Chris Arnold wrote:
> Actually, it is the RedirectMatch specifically causing the problem. How to specify only match http://apps.somesite.tld?
You can't. You have to use RewriteCond (as you have) and then use
"RewriteRule ^/$ /somealias/" in place of the RedirectMatch that you posted.
--
Daniel Ruggeri
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Chris Arnold <ca...@electrichendrix.com>.
On Mon, Apr 15, 2013 at 6:57 PM, Chris Arnold
<ca...@electrichendrix.com> wrote:
> We have a server at http://rootsite.net. We also have another site/app that runs at http://apps.rootsite.net. We host client applications on our server using apache so the above site/app needs to be http://apps.ourclientsdomain.tld. Here is what i have gotten to work in the site/app virtual host file:
>
> ServerName apps.*
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^apps\.
> RedirectMatch ^/$ /somealias/
Did you mean RewriteRule? RewriteCond doesn't limit any other directives.
Actually, it is the RedirectMatch specifically causing the problem. How to specify only match http://apps.somesite.tld?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Eric Covener <co...@gmail.com>.
On Mon, Apr 15, 2013 at 6:57 PM, Chris Arnold
<ca...@electrichendrix.com> wrote:
> We have a server at http://rootsite.net. We also have another site/app that runs at http://apps.rootsite.net. We host client applications on our server using apache so the above site/app needs to be http://apps.ourclientsdomain.tld. Here is what i have gotten to work in the site/app virtual host file:
>
> ServerName apps.*
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^apps\.
> RedirectMatch ^/$ /somealias/
Did you mean RewriteRule? RewriteCond doesn't limit any other directives.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Chris Arnold <ca...@electrichendrix.com>.
On Apr 19, 2013, at 4:48 AM, "Pete Houston" <ph...@openstrike.co.uk> wrote:
> On Mon, Apr 15, 2013 at 06:57:13PM -0400, Chris Arnold wrote:
>> We have a server at http://rootsite.net. We also have another site/app that runs at http://apps.rootsite.net. We host client applications on our server using apache so the above site/app needs to be http://apps.ourclientsdomain.tld. Here is what i have gotten to work in the site/app virtual host file:
>>
>> ServerName apps.*
>>
>> RewriteEngine On
>> RewriteCond %{HTTP_HOST} ^apps\.
>> RedirectMatch ^/$ /somealias/
>>
>> This appears to work, however, it has also taken over our root site. So http://rootsite.net now takes you to http://rootsite/somealias. How can i stop this from happening? I assume i have something amiss in the above rewrite?
>
> Here is a possible solution without mod_rewrite:
>
> <VirtualHost 1.2.3.4:80>
> ServerName rootsite.net
> ... config specific to this site here ...
> </VirtualHost>
>
> <VirtualHost 1.2.3.4:80>
> ServerName apps.rootsite.net
> ServerAlias apps.*
> ... config specific to this other site here ...
> UseCanonicalName Off
> RedirectMatch ^/$ /somealias/
> </VirtualHost>
>
> In this way the Redirect only applies to the virtual hosts which are
> specified and leaves all others untouched. The added bonus is that you
> can avoid loading the heavy mod_rewrite at all.
That does help... I just wanted a way to rewrite http://apps.* to http://apps*/alias. Http://apps. will never change so I was trying to have apache catch the apps. part and rewrite it.
Re: [users@httpd] Rewrite Rule Rewriting root site
Posted by Pete Houston <ph...@openstrike.co.uk>.
On Mon, Apr 15, 2013 at 06:57:13PM -0400, Chris Arnold wrote:
> We have a server at http://rootsite.net. We also have another site/app that runs at http://apps.rootsite.net. We host client applications on our server using apache so the above site/app needs to be http://apps.ourclientsdomain.tld. Here is what i have gotten to work in the site/app virtual host file:
>
> ServerName apps.*
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^apps\.
> RedirectMatch ^/$ /somealias/
>
> This appears to work, however, it has also taken over our root site. So http://rootsite.net now takes you to http://rootsite/somealias. How can i stop this from happening? I assume i have something amiss in the above rewrite?
Here is a possible solution without mod_rewrite:
<VirtualHost 1.2.3.4:80>
ServerName rootsite.net
... config specific to this site here ...
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerName apps.rootsite.net
ServerAlias apps.*
... config specific to this other site here ...
UseCanonicalName Off
RedirectMatch ^/$ /somealias/
</VirtualHost>
In this way the Redirect only applies to the virtual hosts which are
specified and leaves all others untouched. The added bonus is that you
can avoid loading the heavy mod_rewrite at all.
HTH,
Pete
--
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107