Search code examples
.htaccessmod-rewriteurl-rewritingsubdomainsilverstripe

How can I display a subpage of my Silverstripe website as a subdomain?


I have a website build on Silverstripe 3.

Now I want that a user can enter the Subdomain URL info.mydomain.com and see the content of the page mydomain.com/subpage-url/. But without redirection. The subdomain URL should stay in their browser.

I already created the subdomain and let it point to the root directory of my website. As I understand it right I now need some rewrite conditions in my .htaccess file? And that is the point I struggle with. I googled a little bit and did some trail and fail but nothing seems to work. Maybe I understand it totally wrong, used the wrong rewrite conditions or insert them on the wrong place.. Maybe there are Silverstripe specific issues to pay attention to?

Long story short: I need help please!


Solution

  • As Robbie Averill pointed out in his comment, you could install the Subsites module. But you'd have to create a Subsite (eg. a separate site-tree) for every domain.

    There's another module though, the homepagefordomain module. With that module you can specify one (or multiple) domains per page. When you visit one of these domains, the page that was specified as home-page for that domain will show up. I think this is a more flexible approach than messing with the .htaccess file.