Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite with sub folder hosting

Help with Secondary Mod Rewrite

         

layer8

1:52 pm on Aug 10, 2004 (gmt 0)

10+ Year Member




I have a mod-rewrite working on my primary domain set up as follows:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.primarydomain\.co.uk
rewriterule (.*) [primarydomain.co.uk...] [R=permanent,L]

In addition to the primary domain (mainsite) I have a customer's website that is in a subdirectory.

I.E.

www.primarydomain.co.uk/customer-folder/

When I goto www.bluewidgets-customer.net it is actually sent to www.primarydomain.co.uk/customer-folder/ (although I am the only one that knows this)

Now [bluewidgets-customer.net...] and [bluewidgets-customer.net...] are obviously located in www.mainsite.co.uk but how do I set up mode rewrite for this? Just for clarification [bluewidgets-customer.net...] has the PR and the www.bluewidgets-customer.net doesn't have PR which is why I want to sort this out soon.

Do I add new .htaccess in the sub folder or do I do it in the main directory with different lines of code?

Your help would be very much appreciated!

layer8

1:54 pm on Aug 10, 2004 (gmt 0)

10+ Year Member



Just for clarification:

[bluewidgets-customer.net...] and [bluewidgets-customer.net...] are obviously located in www.primarydomain.co.uk and not the www.mainsite.co.uk mentioned above.

Thanks in advance!

layer8

2:03 pm on Aug 10, 2004 (gmt 0)

10+ Year Member



I just tried to put a .htaccess file in the sub directory and it worked.

Thanks form my help me...

Marcia

2:10 pm on Aug 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Congratulations!

What did you do? What did you put into the htaccess in the subfolder?

layer8

2:19 pm on Aug 10, 2004 (gmt 0)

10+ Year Member



Yes...

I created a new .htaccess file and added it to the sub folder and it worked.

(With only one small problem) - I wanted to make all [www...] point to http:// - this really slowed things down so I swaped them around (everything points to www) and it all works.

The only thing I can't see is google's tool bar page ranking but that will most likely change through time ;)

jdMorgan

2:39 pm on Aug 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's what I came up with to do it all in the main .htaccess:

Options +FollowSymLinks
RewriteEngine on
#
# If any bluewidgets-customer domain is requested
RewriteCond %{HTTP_HOST} bluewidgets-customer\.net [NC]
# but not the version we want
RewriteCond %{HTTP_HOST} !^bluewidgets-customer\.net
# then 301-redirect to the version we want (This will result in a new HTTP request for the correct domain)
RewriteRule (.*) http://bluewidgets-customer.net/$1 [R=permanent,L]
#
# If correct bluewidgets-customer domain requested, rewrite it to the correct subdirectory
RewriteCond %{HTTP_HOST} ^bluewidgets-customer\.net
# (next line prevents recursion)
RewriteCond %{REQUEST_URI} !^/customer-folder
RewriteRule (.*) /customer-folder/$1 [L]
#
# If not a customer domain, check for non-preferred main domain and redirect if needed
RewriteCond %{HTTP_HOST} !^primarydomain\.co\.uk
RewriteRule (.*) http://primarydomain.co.uk/$1 [R=permanent,L]

I suspect that when you say it was slow, you may have encountered the recursion problem noted in step two above.

Jim

layer8

2:48 pm on Aug 10, 2004 (gmt 0)

10+ Year Member



Wow, thanks Jim!

Sounds like a good plan of action...;)

Stewart