Web Hosting Forum | Lunarpages
News: October 6, 2008 - Submit Your Site for the October 2008 Site of the Month!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 12, 2008, 04:51:47 PM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: Using .htaccess to change where subdomains point internally  (Read 690 times)
rwoelich
Newbie
*
Offline Offline

Posts: 2


« on: March 02, 2008, 01:35:15 PM »

Hi,

I have a main site (i.e. domain.com) on my hosting account which resides at /public_html/. I also have a number of addon domains (i.e. domain2.com) which reside within their own folders as /public_html/domain2.

If I add a subdomain to one of my addon domains (like subdomain.domain2.com) the folder for the subdomain is created in /public_html/subdomain instead of /public_html/domain2/subdomain where I want it.

How can I use .htaccess or any other method to set up subdomains to internally point to another directory? I'd want the address bar to show as subdomain.domain2.com but the folder it would be using would be /public_html/domain2/subdomain instead of /public_html/subdomain. Thanks!
Logged
Mitch
Lunarpages Traffic Cop
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 7949



WWW
« Reply #1 on: March 03, 2008, 06:07:12 AM »

At this time, sub domains for addon domains is not supported, due to the way cPanel handles them (or doesn't handle them well as the case might be). 
Logged

rwoelich
Newbie
*
Offline Offline

Posts: 2


« Reply #2 on: March 03, 2008, 11:12:58 AM »

Ah, but I disagree! And I'm so close to getting it to work.

So, I have my .htaccess file with the following in my /public_html/ folder:

Code:
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?domain2\.org$ [NC]
RewriteCond %{HTTP_HOST} !^/subdomain/$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain.domain2\.org$ [NC]
RewriteRule ^(.*)$ /domain2/subdomain/index\.html [L]

This seems to work to pick up the subdomain, but I'm getting a 404 not found. I'm not sure what the proper way to point to where I want it to go is. Would I use the /domain2/subdomain/ as I am? Apparently not. I tried the full path on the server, i.e. /home/user/public_html/domain2/subdomain/ and that didn't work either. I tried /public_html/domain2/subdomain/ and that didn't work. I just have the index.html on there so I know I hit that directory when I get it working.

Any gurus see what I'm doing wrong? :p Thanks!

Edit: I changed the rewrite to be index.php just so I could see where I was ending up here. It's in the /public_html/subdomain folder where I don't want. How can I change the rewrite path to get out of the public_html/subdomain/ folder and into the public_html/domain2/subdomain/ one? I tried ../domain2/subdomain but that gave me a Bad Request error.
« Last Edit: March 03, 2008, 11:26:42 AM by rwoelich » Logged
e-niton
Newbie
*
Offline Offline

Posts: 5


« Reply #3 on: March 20, 2008, 01:59:30 PM »

Hi,
Have you had any more luck with this? This is exactly what i need...

Aiming for something like the following

http://www.maindomain.com     --> /public_html/
http://mainsub.maindomain.com --> /public_html/mainsub/

http://www.addon1.com           --> /public_html/addon1/
http://addonsub.addon1.com     --> /public_html/addon1/addonsub/

etc..

I am sure this is possible with mod_rewrite and I think I am going to have a bash to see if I can get it to work. At the same time though I am worried about any impace this may have on FTP access for the addon domains and SEO..
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM