Forum Moderators: phranque
For starters i suck at .htaccess
I did a search for my question on this forum but did not find my answer.
My situation:
I have www.domain.com as my main domain.
I have www.addondomain.com as my addon domain (on the same account as domain.com)
I have images.addondomain.com as a subdomain
The Directories
www.domain.com >> /home/raine/public_html/
www.addondomain.com >> /home/raine/public_html/addondomain/
images.addondoman.com >> /home/raine/public_html/images/
The problem is that cpanel cannot make a subdomain of a addondomain inside it’s own dir...it must go in the root dir.
I was hoping somebody with some .htaccess skill can make one that will do the following:
-When images.addondomain.com gets requested
-Instead of using /home/raine/public_html/images/
-Use /home/raine/public_html/addondomain/images/
Who is going to be my hero!
Maybe something like this? (alternative)
RewriteCond %{HTTP_HOST} ^([^.]+)images\.example\.com [NC]
RewriteCond %{HTTP_HOST}!^www\.images\.example\.com
RewriteRule ^$ /images/%1/ [L]
I don't want the URL to change
[edited by: Raine at 1:57 pm (utc) on Oct. 25, 2007]
# Specific solution (supports only images.example.com)
RewriteCond $1 !^addon/
RewriteCond %{HTTP_HOST} images\.example\.com
RewriteRule (.*) /addon/images/$1 [L]
#
# General solution (supports any add-on subdomain except "www")
RewriteCond $1 !^addon/
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example\.com
RewriteRule (.*) /addon/%2/$1 [L]
Jim
MAIN DOMAIN: www.maindomain.com
ADDON DOMAIN: www.addondomain.com
ADDON SUBDOMAIN: images.addondomain.com
With your solution when i visit images.addondomain.com
it will be translated to www.addondomain.com/addon/images/ right? (or i got it all wrong?)
Since the directory for images.addondomain.com is:
/home/raine/public_html/images/
and the directory for www.addondomain.com is:
/home/raine/public_html/addondomain/
I cannot access /home/raine/public_html/images/ with www.addondomain.com i can only access that directory with images.addondomain.com
So basically my question is:
Is there a way to make a .htacces that will make a subdomain use an alternate directory? (remember i cannot access that directory with www.addondomain.com)
If that is impossible or too difficult, maybe another solution is:
-When images.addondomain.com get requested
-Translate that to www.addondomain.com/images/
-Without changing the URL.
-This must also work if i use images.addondomain.com/uploads/example.gif
-That must be translated to: wwww.addondomain.com/images/uploads/example.gif
-Without changing the URL.
I hope you can help me with that.
[edited by: Raine at 2:39 pm (utc) on Oct. 25, 2007]
If it differs from the directory for you main site, then perhaps you can use *nix symbolic links to allow access to the directory paths you need.
Jim
So i guess the .htacces should go there.
I think the best solution is this one >>
-When images.addondomain.com get requested
-Translate that to www.addondomain.com/images/
-Without changing the URL.
-This must also work if i use images.addondomain.com/uploads/example.gif
-That must be translated to: wwww.addondomain.com/images/uploads/example.gif
-Without changing the URL.
Could you make an example of a .htaccess that will do the above?
I will test it out and see if it works and modify it too my needs.
Thanks for your time and patience.