Seperate Domains for Subfolders + URL Cloaking

Using a single web hosting account to host multiple sites

Seperate Domains for Subfolders + URL Cloaking

Postby th3n33ms » Wed Jul 25, 2007 7:55 pm

Hey guys

I currently have a setup so that visitors to my domain get forwarded to the a /wp/ folder and the rest of the url is cloaked. I would like to duplicate that for another two subdomains that would serve as domain roots. My current setup on my server (for the one domain not under a subfolder) is....

My root directory had a folders and also had the folder /wp/
If you went to just my domain it would redirect you to /wp/ and then cloak the /wp/ from the address bar, but if you went to mydomain.com/folder/ it would take you to that folder
It also had it so that if you went to any page within /wp/ it would keep the cloak of mydomain.com/pagewithinwp/

The htaccess looked like this.



Options +FollowSymLinks

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/projects%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{REQUEST_URI} ^(/[^/]+)
RewriteCond %{DOCUMENT_ROOT}/projects%1/ -d
RewriteRule ^(.*)$ /projects/$1 [QSA,L]

RewriteCond %{DOCUMENT_ROOT}/wp%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/wp%{REQUEST_URI} -d
RewriteRule !^wp(/.*)?$ /wp%{REQUEST_URI} [QSA,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !^wp/index.php$ /wp/index.php [L]


Now in my new site I have two folders in my root, one for one domain and another for the other domain. The folders are th3n33ms and kingnima.
I would like to do the same kind of htaccess but have it so if someone goes to kingnima.com it will redirect them to the kingnima/wp folder and also cloak the actual domain from the address bar and then do the same to the th3n33ms.net domain.

Basically I want the same setup as before except the redirection would go down two levels (directory wise) instead of two.

Both th3n33ms.net and kingnima.com go to the same page right now so either of them are interchangeable for the output directory as long as it is cloaked.

So http://th3n33ms.net --> http://th3n33ms.net/th3n33ms/wp
http://th3n33ms.net/folder --> http://th3n33ms.net/th3n33ms/folder
http://kingnima.com --> http://th3n33ms.net/kingnima/wp
http://kingnima.com/folder --> http://th3n33ms.net/kingnima/folder

Anyways, if you could help me with this it would be amazing I'd find some way of repaying you. If you can't if you could just tell me where I could post this on the forum that would be great too.


Thanks a lot



Nima
th3n33ms
 
Posts: 6
Joined: Sun Jun 03, 2007 3:33 pm

Postby richardk » Thu Jul 26, 2007 2:37 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI} -d
RewriteRule !^(th3n33ms|kingnima)/wp(/.*)?$ /wp%{REQUEST_URI} [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI} -d
RewriteRule !^(th3n33ms|kingnima)(/.*)?$ /%3%4%{REQUEST_URI} [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !^(th3n33ms|kingnima)/wp/index.php$ /%3%4/wp/index.php [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby th3n33ms » Thu Jul 26, 2007 7:49 pm

Hey richardk,
I applied the .htaccess and it worked great except for one part. When you put in a url such as th3n33ms.net/music it converts to th3n33ms.net/th3n33ms/music, is there a way to keep it from doing this (on both domains) and make it so it only shows th3n33ms.net/folder or kingnima.com/folder

Also, I'm not sure if this is .htaccess related but it seems that when I try to go to just a directory such as th3n33ms.net/music it is a 403 Forbidden error, is there a way to make it so that all folders are open to viewing?


Thanks a lot for your help!
th3n33ms
 
Posts: 6
Joined: Sun Jun 03, 2007 3:33 pm

Postby richardk » Fri Jul 27, 2007 1:26 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Remove the hidden directory if it shows.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^https?://(www\.)?th3n33ms\.net/th3n33ms(/(.*))?$ [NC,OR]
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^https?://(www\.)?kingnima\.com/kingnima(/(.*))?$ [NC]
RewriteRule .* /%3 [R=301,L]

# Add missing trailing slashes.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Wordpress files.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI} -d
RewriteRule !^(th3n33ms|kingnima)/wp(/.*)?$ /wp%{REQUEST_URI} [QSA,L]

# Other files.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI} -d
RewriteRule !^(th3n33ms|kingnima)(/.*)?$ /%3%4%{REQUEST_URI} [QSA,L]

# Anything that doesn't exist to Wordpress.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !^(th3n33ms|kingnima)/wp/index\.php$ /%3%4/wp/index.php [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby cypherbud » Sat Jul 28, 2007 3:14 pm

richardk wrote:Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Remove the hidden directory if it shows.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^https?://(www\.)?th3n33ms\.net/th3n33ms(/(.*))?$ [NC,OR]
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^https?://(www\.)?kingnima\.com/kingnima(/(.*))?$ [NC]
RewriteRule .* /%3 [R=301,L]

# Add missing trailing slashes.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI}/ -d [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Wordpress files.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4/wp%{REQUEST_URI} -d
RewriteRule !^(th3n33ms|kingnima)/wp(/.*)?$ /wp%{REQUEST_URI} [QSA,L]

# Other files.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%3%4%{REQUEST_URI} -d
RewriteRule !^(th3n33ms|kingnima)(/.*)?$ /%3%4%{REQUEST_URI} [QSA,L]

# Anything that doesn't exist to Wordpress.
RewriteCond %{HTTP_HOST} ^(www\.)?((th3n33ms)\.net|(kingnima)\.com)$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !^(th3n33ms|kingnima)/wp/index\.php$ /%3%4/wp/index.php [L]


Dude ... I have been searching for about 48 hours, over the course of 2 weeks for some kind of code example like this! It works, all my domains work within my one hosting account ...!

I'm a firm believer of even though it isn't broken, make sure you optimize it. So naturally, I have a question for you. Just as any programming language would use ... is there a way to make some kind of an apache/mod_rewrite version of an array so I don't have a million lines of code for all the domains I have hosted on one single account? And if there is a possibility, how would I use it with the example directly above this response?

----

Edit:

Can you explain how to use this example for more than 2 domains, and non-wordpress domains, in addition to my above question?

Thanks ahead of time.
Sean
----
Last edited by cypherbud on Wed Aug 01, 2007 1:18 pm, edited 1 time in total.
cypherbud
 
Posts: 4
Joined: Sat Jul 28, 2007 3:07 pm

Postby th3n33ms » Mon Jul 30, 2007 12:24 pm

I applied that .htaccess to the root folder of my hosting and I keep getting a 500 Internal Server Error on any page I try to access? Any ideas why this is happening?
th3n33ms
 
Posts: 6
Joined: Sun Jun 03, 2007 3:33 pm

Postby cypherbud » Wed Aug 01, 2007 1:21 pm

th3n33ms wrote:I applied that .htaccess to the root folder of my hosting and I keep getting a 500 Internal Server Error on any page I try to access? Any ideas why this is happening?


Are you using his code for more than 2 domains (Primary hosted domain, and alias)? I had some trouble when I added in all 8 my domains ... pointing all of them to their correct folders using a non-wordpress setup.

I asked richardk via Private Message ... if he could come back to this forum and help us out.
cypherbud
 
Posts: 4
Joined: Sat Jul 28, 2007 3:07 pm

Postby th3n33ms » Wed Aug 01, 2007 3:43 pm

No I just have two domains, the Wordpress database isn't set up yet but all the files are there and the other folder has just an index but nothing else. The previous .htaccess worked fine (no 500 errors or anything but not the exact requirements I wanted) so I don't know whats wrong with this one.


I am a complete novice at .htaccess but as I was looking at the .htaccess you provided I noticed that the Wordpress rules are for both the kingnima and th3n33ms domains, if there is no wordpress installation (or folder) in the kingnima directory would that cause a problem?
th3n33ms
 
Posts: 6
Joined: Sun Jun 03, 2007 3:33 pm

Postby cypherbud » Wed Aug 01, 2007 4:11 pm

th3n33ms wrote:No I just have two domains, the Wordpress database isn't set up yet but all the files are there and the other folder has just an index but nothing else. The previous .htaccess worked fine (no 500 errors or anything but not the exact requirements I wanted) so I don't know whats wrong with this one.


I am a complete novice at .htaccess but as I was looking at the .htaccess you provided I noticed that the Wordpress rules are for both the kingnima and th3n33ms domains, if there is no wordpress installation (or folder) in the kingnima directory would that cause a problem?


I am just about to break my novice'ness ... as everytime I change my mod_rewrite coding, I learn more and more.

I quoted richardk above.

I believe it might cause some kind of problem if you are trying to point to a folder that isn't there (physically, or creating it with mod_rewrite). Regardless, until you install wordpress ... create the folder /wp/ off of both domains, and see if it works properly.
cypherbud
 
Posts: 4
Joined: Sat Jul 28, 2007 3:07 pm

Postby th3n33ms » Wed Aug 01, 2007 8:58 pm

I created a wp folder in the kingnima folder and put a index.php in there and wp is already populated with the WordPress files in th3n33ms but I still get a 500 Internal Error. Any more ideas?
th3n33ms
 
Posts: 6
Joined: Sun Jun 03, 2007 3:33 pm

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 3 guests

cron