Subdomain, redirect ;) little help pls

Using a single web hosting account to host multiple sites

Subdomain, redirect ;) little help pls

Postby redpicasso » Tue Feb 27, 2007 6:09 am

Hi all,
1st sorry for the title i didn't know how to name the topic :)
I've read almost all topics in the forum, but my english is not very good, so i need some help.
With simple words i want subdomains, now i'm using this code:
Code: Select all
Options +FollowSymLinks

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.redpicasso\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.redpicasso\.com [NC]
RewriteRule ^(.*)$ http://www.redpicasso.com/home/%1 [QSA,L]

It works fine, but the only problem is that:
when someone uses www.alex.redpicasso.com or http://alex.redpicasso.com it redirects to www.redpicasso.com/home/alex/
thats ok but it changes the address to www.redpicasso.com/home/alex/ and i don't want that...
For example when i use:
Code: Select all
<VirtualHost 85.130.66.38:80>
ServerName www.redpicasso.com
ServerAlias alex.redpicasso.com www.alex.redpicasso.com
DocumentRoot C:/home/alex
</VirtualHost>

the result is exactly what i want, the address is alex.redpicasso.com and it doesen't change to www.redpicasso.com/home/alex/ even the user is in www.redpicasso.com/home/alex/music/ or something like this the address remains www.alex.redpicasso.com/music/

How can i do this with mod_rewrite?
10x :)
redpicasso
 
Posts: 6
Joined: Tue Feb 27, 2007 5:42 am

Postby richardk » Tue Feb 27, 2007 9:33 am

You need all the sub domains to go to the main document root, then you can use this
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.redpicasso\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.redpicasso\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/home/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.redpicasso\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.redpicasso\.com$ [NC]
RewriteRule ^(.*)$ /home/%2/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby redpicasso » Tue Feb 27, 2007 11:23 am

All the subdomains to the main document root...you mean this:
*.redpicasso.com A 85.130.66.38
redpicasso.com A 85.130.66.38

Now I get 404 Error but i'll think how to fix it :)
10x :)
redpicasso
 
Posts: 6
Joined: Tue Feb 27, 2007 5:42 am

Postby redpicasso » Tue Feb 27, 2007 11:57 am

I found where is the problem, but i don't know how to fix ti :)
my /home/ is alias...
if I use a folder witch is in tha apache htdocs directory it works perfectly :) but when i try with my alias folder it doesn't :)
Can you help me?
Thank you again :)
redpicasso
 
Posts: 6
Joined: Tue Feb 27, 2007 5:42 am

Postby redpicasso » Thu Mar 01, 2007 11:30 am

Iei :) i changed 2 things and it worked :)
Thank you for your help richardk :) if you come to Bulgaria you'll have beer from me :)
redpicasso
 
Posts: 6
Joined: Tue Feb 27, 2007 5:42 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 18 guests

cron