views:

433

answers:

1

Basically I want *.domain.com to pull up domain.com/*/ (not redirect).

I went into the subdomains section of cPanel and set a wildcard for this domain. It appears to be resolving correctly, ie *.domain.com is bringing up domain.com.

I've now made a htaccess file in the public_html directory containing:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
RewriteRule (.*) %2/$1 [L]

The error I'm getting is '500 Internal Server Error', any ideas?

A: 

Try this rule:

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.example\.com$ [NC]
RewriteCond %2%{REQUEST_URI} !^([^/]+)/\2
RewriteRule (.*) %2/$1 [L]

The addtional RewriteCond %2%{REQUEST_URI} !^([^/]+)/\2 should avoid infinite loops caused by the L flag.

Gumbo