Jump to content

Rewriting subdomains with subfolders


Michan

Recommended Posts

Hi,

 

I've managed to successfully rewrite subdomains to folders, so that http://username.mysite.com will go to http://mysite.com/user.php?user=username

 

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:

http://username.mysite.com (profile)

http://username.mysite.com/blog (blog)

http://username.mysite.com/photos (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.

Link to comment
Share on other sites

  • 3 weeks later...

last rewrite rule...

 

RewriteRule (.*) user.php?user=%1 [L]

 

im not 100% familiar with the .htacess file and using it properly, but this could be just me, but I dont ever remember the mention having to use a %.. could be wrong, or could be a typo, just wanted to mention it as something I took notice to.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.