Forum Moderators: phranque
I've managed to successfully rewrite subdomains to folders, so that [username.mysite.com...] will go to [mysite.com...]
However, I'm having trouble directing extensions of that subdomain to other areas of the site.
For example, each user has their own blog and photo gallery, so the following urls should exist:
[username.mysite.com...] (profile)
[username.mysite.com...] (blog)
[username.mysite.com...] (photos)
Here is my code:
RewriteCond %{HTTP_HOST} !(^\www\b¦^\ftp\b¦^\mail\b¦^\webmail\b).mysite\.
RewriteCond %{HTTP_HOST} ^www.([^/]+).mysite.com/blog/?$ [OR]
RewriteCond %{HTTP_HOST} ^([^/]+).mysite.com/blog/?$
RewriteRule (.*) blog.php?user=$1 [L]
RewriteCond %{HTTP_HOST} !(^\www\b¦^\ftp\b¦^\mail\b¦^\webmail\b).mysite\.
RewriteCond $1 !^blog/?
RewriteCond %{HTTP_HOST} ^www.([^/]+).mysite.com/?$ [OR]
RewriteCond %{HTTP_HOST} ^([^/]+).mysite.com/?$
RewriteRule (.*) user.php?user=%1 [L]
As you can see, I've started with the blog, but it just keeps giving me an error every time I try typing the url (although the profile continues to display the page correctly).
I've tried searching but couldn't find any success, so any insight/help would be extremely appreciated!
Thanks in advance.
[edited by: Michan at 10:10 pm (utc) on Mar. 4, 2008]
RewriteCond %{HTTP_HOST} !^(www¦ftp¦(web)?mail)\.mysite\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.mysite\.com
RewriteRule ^(blog¦photos)/ /$1.php?user=%2 [L]
#
RewriteCond $1 !^user\.php$
RewriteCond %{HTTP_HOST} !^(www¦ftp¦(web)?mail)\.mysite\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.mysite\.com
RewriteRule (.*) /user.php?user=%2 [L]
I assume that the PHP script is extracting the originally-requested URL-path from a server variable, since that URL-path is being replaced by the script's URL-path in both rules. I further assume that the script can handle requests for image, css, multimedia, external JavaScript, privacy policy, content labeling, xml sitemap, and robots.txt files.
Replace all broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifies the pipe characters.
Jim