Search code examples
.htaccessurlurl-rewritingsubdomain

Show url of a subfolder as a subdomain with htaccess


Hope someone can help. I'm looking for a way to show the url of a website folder like a subdomain.

Let's say that I have a website www.example.com and a subfolder www.example.com/sub. Is it possible to show the url like www.sub.example.com instead of www.example.com/sub using htaccess' url rewrite, without moving the resources of the sub folder to a "real" subdomain? In other words, is it possible to change only the address of the sub folder?

Thanks a lot.


Solution

  • You can do this in the hosting control panel by creating the subdomain, which may be the cleaner method...

    You can see a similar thread here: .htaccess Subdomain Redirection (archive.org mirror).