Forum Moderators: phranque

Message Too Old, No Replies

subdomain to different folder

on shared hosting

         

Salami1_1

9:16 am on Jun 23, 2009 (gmt 0)

10+ Year Member



Hi,

I'm on a shared hosting environment and when I create a subdomain it will create a same named folder in my public_html dir but I want a subdomain to point to a different folder in my public_html.

I talked to the webhost (host1plus) but they say this is a global setting which can't be changed.

So now im trying to create a work-around by using htaccess to point everything from:
[nl.domain.com...] (=> public_html/nl/ )
to public_html/ln/

I've tried the following
in .htaccess in public_html/:

RewriteCond %{HTTP_HOST} ^nl\.domain\.com [NC]
RewriteRule ^(.*)$ ln/$1 [L]
which gives 403 error

in .htaccess in public_html/nl/
RewriteRule ^(.*) domains/domain.com/public_html/ln/$1
and
RewriteRule ^(.*) ln/$1
Both give 500 errors

and
RewriteCond %{HTTP_HOST} ^nl\.domain\.com [NC]
RewriteRule ^(.*)$ ln/$1 [L]
and
RewriteCond %{HTTP_HOST} ^nl\.domain\.com [NC]
RewriteRule ^(.*)$ domains/domain.com/public_html/ln/$1 [L]

which also gives errors (500).

I'm running out of ideas to try to fix this. Can someone point me in the right direction.

Thank you very much.

Best regards,

jdMorgan

12:47 pm on Jun 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is likely that DocumentRoot for each subdomain is set to a unique subdirectory, and mod_rewrite cannot "see" above its document root. You can go "down" from the DocumentRoot, but you cannot go "up." Therefore the filespace you want to 'share' between subdomains is not accessible.

You'll need to either change hosting companies or change to a different level of hosting account.

The cheapest solution is likely to get an "IP-based virtual hosting account." This gives you the freedom to map any subdomain or domain you like to any directory in your account filespace. In the U.S. the typical difference in cost between a name-based virtual hosting account and an IP-based virtual hosting account is $1.00 per month. I'm not sure about .nl or EU pricing, but it should be comparable.

[added] When you get a 500-Server Error, look at your server error log file -- It often contains very useful information to identify the problem. [/added]

Jim

[edited by: jdMorgan at 12:50 pm (utc) on June 23, 2009]

Salami1_1

6:36 am on Jun 25, 2009 (gmt 0)

10+ Year Member



Hi Jim,

Thanks for your reply.. I actually just switched to this new hosting because they offer multiple server locations which I want to use to make my site faster on different parts on the world and improve SEO.. so that is bad news for me..

Now I though of something that partly solves my problem and I think I can tweak it to make it fully working.

Every request on one of my sub domains is now via .htaccess parsed via 1 file called 'fetch.php' which does some checks and just includes the necessary file from the other folder and displays it. All file requests are working now.. just need to fix the 'virtual folder links' on the subdomains to work but I think I can figure that out also.

Best regards,