Hey everyone!
It's either I am an idiot or I'm not seeing something very obvious. (probably the former :)
I am trying to do a redirect based on the domain that the request is coming. I have several domains parked. In my SiteTree I have a simple structure - a holder page on the top level, one for each domain, named after the domain without the .com/.net part.
Like this:
> Root
->Domain1
-->SubpageA1
-->SubpageA2
-->...
->Domain2
-->SubpageB1
-->SubpageB2
...
When a request to my default domain, the regular deep linking is applied, eg.
www.defaultdomain.com/domain1/subpageA1 is alright.
When a request comes from Domain1.com, however, I would like the url to be parsed without repeating domain, eg:
instead of
www.domain1.com/domain1/subpageA1
In .htaccess, I have tried:
RewriteCond %{HTTP_HOST} !www\.defaultdomain\.com [NC]
RewriteCond %{HTTP_HOST} ^www\.([A-Z,a-z,0-9,\_]*).* [NC]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1/%2&%{QUERY_STRING} [L]
but it's not working. Then I notice the url variable in htaccess, which I assume gets processed somewhere - at which point?
Perhaps I should pass the whole thing, domain, and deep links, to the url and then work with it somewhere in SilverStripe? e.g. htaccess would send a full request to sapphire/main.php?url=www.domain1.com/subpageA1, then I would somehow split the url variable in PHP and then display the correct page. No clue if there's a different method than Director::redirect to pull a particular Page from the SiteTree and display it without changing the actual URL.
I -have- tried Director::redirect... but that one displays the new url with the redirect. I was even able to get the appropriate page ID based on the domain, but I can't seem to get Director to just display a particular page object, but not redirect.
Hope this makes sense, I've been killing myself over this for 2+ months.