Moving domain into a Subfolder.

Using a single web hosting account to host multiple sites

Moving domain into a Subfolder.

Postby spastikman » Mon Sep 01, 2008 12:46 am

Thank you for reading. I've read over 15 forums and modified my .htaccess so many times over the past week with very little success

I need a domain to work completely within a subfolder without giving away that its within that subfolder (have the client only see the domain.com)

I was able to get it to work on a pretty basic level, but haven't figured anything out that is flexible enough to work with multiple subfolders within the redirected subfolder.

This is what I've had the MOST success with:
Code: Select all
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$

RewriteCond %{REQUEST_URI} !^/subfolder/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /subfolder/$1

RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]

That fixes the main page to show up nicely, but very little else. I have a folder within my site that I use to install all kinds of open source software like coppermine, pmwiki, modx, dada mail etc. If I navigate to those, the subfolder always shows or it won't work period.

edit: oh and I'm using shared hosting. So the subfolder would be within /home1/username/public_html/subfolder
spastikman
 
Posts: 2
Joined: Mon Sep 01, 2008 12:30 am

Postby richardk » Tue Sep 02, 2008 11:29 am

Do you have any files or directories for this domain that are not in the sub directory?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ /subfolder/$1 [QSA,L]


I have a folder within my site that I use to install all kinds of open source software like coppermine, pmwiki, modx, dada mail etc. If I navigate to those, the subfolder always shows or it won't work period.

If they have there own mod_rewrite that might need editing. Also be aware that mod_rewrite does not change the links that are outputted by these scripts, so if they have a base URL setting that might need changing.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby spastikman » Tue Sep 02, 2008 11:58 am

you are amazing. You should leave a paypal link as your signature.
spastikman
 
Posts: 2
Joined: Mon Sep 01, 2008 12:30 am

Postby yoepus » Wed Oct 15, 2008 1:07 pm

richardk wrote:Do you have any files or directories for this domain that are not in the sub directory?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ /subfolder/$1 [QSA,L]


If they have there own mod_rewrite that might need editing. Also be aware that mod_rewrite does not change the links that are outputted by these scripts, so if they have a base URL setting that might need changing.


I've tried this for a similar problem I am having; however I run into this problem.

If I try to access www.example.com/folder/index.html
It loads the URL as follows: www.example/sub_folder/folder/index.html
I'd want it to display the first URL; however is this normal behaviour?
If not, what can be done?

Thank you!
yoepus
 
Posts: 1
Joined: Wed Oct 15, 2008 1:02 pm

Postby richardk » Thu Oct 16, 2008 6:32 am

I'd want it to display the first URL; however is this normal behaviour?
If not, what can be done?

That mod_rewrite should keep the first URL in the browser's address bar, is that not happening for you?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 16 guests

cron