Mod_rewrite subdomain problem

After moving to DreamHost, only thing which is not working is subdomain referring mod_rewrite in htaccess.
Its something like that:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^.htaccess$ - [F]
RewriteCond %{HTTP_HOST} ^([^.]+) [NC]
RewriteRule .* /home/[USERNAME]/ [L]

With this, every site member has a unique profile page automatically without adding subdomain from control panel by hand.
It was working with the old server. But its not working on DreamHost.

Anyone can help?

I’m no rewrite expert, but it appears that you’re trying to rewrite using a UNIX path, and not a website path. Or does your domain directory have subdirectories with full paths like:

If this is so, then you’re already creating FTP users here and doing a lot of work. It’s just about as easy to create the subdomain and create a new user during the same process.


I am having a somewhat similar problem. I’m re-directing all of my urls to a single PHP file (/config/paths.php), and my .htaccess script is as follows:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /config/paths.php [L]

This isn’t working in re-directing and only shows the root-level directory listing. What am I doing wrong?

You’ve got two problems here. First, as sdayman pointed out, you need to use URI paths, not filesystem paths. In other words, remove “/home/[USERNAME]/” from your RewriteRule.

The second problem is that what you’re trying to do requires wildcard DNS. If Dreamhost has set this up for you already, great, but it isn’t enabled by default and you can’t turn it on yourself via the panel. You’ll have to submit a support ticket to request this.

If you want useful replies, ask smart questions.