-1

Well I'm working on a software that uses mod_rewrite to route everything to the index.php page, but it becomes problematic with subdomains such as subdomain.example.com. In theory, it should resolve to example.com/subdomain, but it does not work this way.

So I wonder, can anyone please let me know if theres a way to route subdomain.example.com to example.com/subdomain using .htaccess? Thanks.

Lord Yggdrasill
  • 3,197
  • 4
  • 26
  • 42
  • Look here: http://stackoverflow.com/questions/16758204/redirect-wildcard-subdomains-to-subdirectory-without-changing-url-in-address-ba – HarryFink Jan 27 '14 at 08:18

1 Answers1

0

try :

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^[^.]+\.example\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.example\.com(.*) http://www.example.com/$1 [L,R]
Georgio
  • 149
  • 3