Mod_rewrite subdomain problem


#1

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} ^([^.]+).seyvet.com [NC]
RewriteRule .* /home/[USERNAME]/DOMAIN.com/profile.php?id=%1 [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?


#2

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:
/home/YOURUSERNAME/YOURDOMAIN.com/home/USERNAME/DOMAIN.com

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.

-Scott


#3

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?


#4

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]/DOMAIN.com” 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.