0

Background

We are trying to map a subdomain to a regular EE template group, without changing the URL.

Assume that the 'natural' URLs to the templates would look something like this:

my-domain.com/group
my-domain.com/group/url-title

The desired subdomain set up would therefore look something like this:

group.my-domain.com
group.my-domain.com/url-title

The rewrite rule we have set up on the subdomain looks something like this:

RewriteRule ^(.*)$ http://my-domain.com/group/$1 [P]

which, as I understand, will proxy the request to the 'natural' URL.

The Problem

The problem we are having is that by the time the proxied request hits the server, the /group portion of the URL has been duplicated. So the request ends up looking something like this:

my-domain.com/group/group/url-title

which obviously doesn't work.

Debugging

  • If I remove the [P] flag, the rewriting works correctly. (i.e. the request ends up looking something like my-domain.com/group/url-title).
  • I have tried using other segments after the domain in the rewrite rule, (just fake ones e.g. /abc) and the same thing happens with them.

Could there be anything ExpressionEngine is doing to handle / map a request which could be affecting a proxied request?

1 Answer 1

0

Whilst I don't completely understand why it works, we do have a solution that works, so I thought I would post it here.

The rewrite rule now looks like this:

RewriteRule ^(?:group)?(.*) http://my-domain.com/group/$1 [P]

which correctly redirects as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.