FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: doctoreast on February 04, 2007, 07:44:52 PM

Title: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 04, 2007, 07:44:52 PM
  Newbie here, a bit confused by your instructions on how to
use multiple domain names with subdirectories using .htaccess
The original thread is HERE (http://forum.freepgs.com/?topic=584.msg2327#msg2327).

  Why did member "x" called these instructions cheap and amateurish?

  These instructions tell me that I must ask you to add *.mydomain.com to
my account, but I got an error, unacceptable characters, using the *,
when adding it using the Setup Domains page.

   Using two domain names, can someone please clarify how to modify
these scripts, if the two domain names are actually called:
domain1.com and domain2.com

If you need to apply this change to only ONE domain,
put this code in /.htaccess (root):


RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?EXAMPLE.NET$
RewriteRule ^(DIRECTORY\/)?(.*)$ DIRECTORY/$2 [L]



Then, in DIRECTORY/.htaccess (subdomain folder), write
the following code:


RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?EXAMPLE.NET$
RewriteRule ^(DIRECTORY/)?(.*)$ http://www.EXAMPLE.NET/$2 [L,R=301]



Thanks in Advance,
East


Title: Re: '07: Multiple Domain Names using .htaccess
Post by: bonehead on February 05, 2007, 02:14:25 AM
Set your domain dns to the servers dns ips. Set the secondary domain dns to the ip or to the http folder like http://www.???.???/folder

Then contact support and have them set the server to your account and folder.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 06, 2007, 12:53:57 AM
Bonehead,

  After some thought, I think that yours is the correct
process; and that the entire rewrite/htaccess idea
appears to be an attempt by admin to eliminate the 
work of adding vhosts; which is understandable.

  One of my hosting companies has me on one of those
plesk servers with some music download site, who keeps
writing me about content, wanting me to stay away from
the ram (doesn't want me to use any media files).  Well,
I don't have any at all.  This nonsense just has me weary,
and I may just jump ship, which is why I am looking into this.

  Looks like freepgs may not want to handle this your way,
and so I may have to do it their way.  I've emailed admin, but
they have not yet replied.

Thanks,
East
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 06, 2007, 02:23:18 AM
Update: admin has added *.doctoreast.com
to my account, and so it looks like this is now
going to work. I've changed hosting info on
my 2nd domain name, and am waiting for it to
propogate.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 06, 2007, 02:51:37 AM
If you still need help with htaccess I can try, I have subdomains off of one main domain set up and working on my account, I'm not sure how different regular domains would be to set up (I'm assuming not much).
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 06, 2007, 03:52:20 AM

   Still waiting, 24hrs, for hosting ip
to propogate.  I googled this subject,
and came up with some handy links.

http://corz.org/serv/tricks/htaccess2.php?page=all

Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 07, 2007, 02:30:33 AM
Resolved:
Solution was not to add *.mydomain.com to my
account for the second domain name, but to add the
second domain name itself, and then to use the
two .htaccess scripts to redirect it to a subfolder
of my main domain.  Both of the scripts, root and
subfolder, I put my second domain folder & name
info.

http://www.youtube.com/watch?v=6xhYk9PEmXA&mode=related&search=

PE

Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 08, 2007, 04:40:16 PM
Hi,
  Do I need to put .htaccess scripts in all folders?  For some
strange reason,

http://wholives.com/forum
is coming up as
http://wholives.com/wholives/forum

eAst
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 08, 2007, 07:45:32 PM
just in the root folder, and one in the /wholives folder should be sufficient. If you already have one in both post the contents of those files here. If you don't, post the contents of the one that you do have here. (the mod_rewrite parts anyway)
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 08, 2007, 09:03:12 PM
Hi,
Doesn't do it every time, but nearly every time:
Gallery is doing the same:

http://wholives.com/forum
http://wholives.com/gallery


Root (doctoreast.com has)

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?wholives.com$
RewriteRule ^(wholives\/)?(.*)$ wholives/$2 [L]


domain2 (/wholives, wholives.com) folder

RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?wholives.com$
RewriteRule ^(wholives/)?(.*)$ http://www.wholives.com/$2 [L,R=301]



Thanks in Advance,
east
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 08, 2007, 11:28:11 PM
Alright, try this:

Change the first (root) file to:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^wholives.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.wholives.com$
RewriteRule ^(.*)$ wholives/$1 [L]

And in the domain2 folder change the htaccess file to:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.wholives.com$
RewriteRule ^(wholives/)?(.*)$ http://www.wholives.com/$2 [L,R=permanent]

That's (similar) to how I have mine set up and I don't suffer from the directory after the domain problem that you seem to be having. Let me know if that doesn't work and I'll see if I can find another solution.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 08, 2007, 11:46:18 PM
Brainiac,
  Still does the same thing. 
I deleted cookies and cache,
but no help either.

  If you guys want the forum
header for freepgs, just let me know.

East
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 09, 2007, 01:26:00 AM
Are you sure? I just visited wholives.com and clicked the forum link and it didn't add anything odd in the path for me...
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 09, 2007, 02:04:58 AM
B,
  Gallery and Forum is doing this. 
I'm using IE, not FF.  I killed cache/cookies,
rebooted, and it;s still adding the sub folder.

Does it if I click these links here or enter
http://wholives.com/forum
http://wholives.com/gallery
into address bar

Mike
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 09, 2007, 02:48:03 AM
how interesting...if I end the link with a / or a /index.php then it doesn't change the directory. If I DON'T end it with a /, it DOES change the directory. Do you have multiviews on by chance? If so turn that off and try it again, if not I'll look more into that htaccess file.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 09, 2007, 03:18:20 AM
I'm using IE 6.  Is multi-views IE7 or what?
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: acidbath on February 09, 2007, 03:40:18 AM
this method used to work for me but i just tried it today and i get a 500 internal server error.

i know i have everything setup correctly.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 09, 2007, 04:04:57 AM
@doctoreast
No, it's an option you turn on in your account.

http://system.freepgs.com/options.php
Then login
Then hit "Set Scripting Options"
Look under "General Settings" and see if "MultiViews" is set to disabled. If it isn't set it to disabled and try again.

If it's already set to disabled post back here.

@acidbath
Post your entire htaccess file, the most common problem is that it contains an "Options" directive, because they're not allowed.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 09, 2007, 04:11:00 AM
B,
  It is & was disabled.
Thanks,
East
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 09, 2007, 04:35:36 AM
Alright, try changing the htaccess file in the second domain's folder to this (I haven't actually tested it, so it might trigger a 500 server error):

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.wholives.com$
RewriteRule ^(wholives/)?(.*)$ http://www.wholives.com/$2 [L,R=permanent]

RewriteCond %{HTTP_HOST} ^www.wholives.com$
RewriteRule ^(wholives/)?(.*)$ http://www.wholives.com/$2 [L,R=permanent]

(the two new lines check to see if the domain name is wholives.com and if the directory you are in is "wholives" if so, it SHOULD rewrite it, like I said, haven't tested though)
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 09, 2007, 05:07:52 AM
No luck, 500 error


Also; for the record:
These below locked me out of forum and gallery,
could not login...


#BAD, CANNOT LOGIN
Change the first (root) file to:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^wholives.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.wholives.com$
RewriteRule ^(.*)$ wholives/$1 [L]

And in the domain2 folder change the htaccess file to:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.wholives.com$
RewriteRule ^(wholives/)?(.*)$ http://www.wholives.com/$2 [L,R=permanent]
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: brainiac744 on February 09, 2007, 06:23:26 AM
I'm starting to run out of ideas from my limited pool of mod_rewrite knowledge. Try adding this to the BEGINNING (right after RewriteEngine on) of the domain2 folder:

RewriteCond    %{REQUEST_FILENAME}  -d
RewriteRule    ^(.+[^/])$           $1/  [R]

(clear your cache and refresh to see if that works)

What it SHOULD do is rewrite the directory to have a trailing /, which seems to make the redirect work right for me anyway.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 09, 2007, 09:59:39 AM

No luck there either, it adds server root
to the address bar, after http://domainname.com
This is really not all that important to me right now.
If you do think of something, please pm or email it to me.

I appreciate your support, and time with this. As
you can see, the site is coming together fairly
quickly. Anything there, you guys are welcome to
have, just grab it or let me know if you need
something sent.

Many Thanks,
East

Title: Re: '07: Multiple Domain Names using .htaccess
Post by: acidbath on February 10, 2007, 09:36:25 PM
Quote from: doctoreast on February 09, 2007, 02:04:58 AM
B,
  Gallery and Forum is doing this. 
I'm using IE, not FF.  I killed cache/cookies,
rebooted, and it;s still adding the sub folder.

Does it if I click these links here or enter
http://wholives.com/forum
http://wholives.com/gallery
into address bar

Mike

i know exactly why it does this.

by default smf will install to the /wholives/forum/ directory
now that would be correct as a root dir but not as the url....

you need to fix the settings within smf and it will be fixed.
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on February 11, 2007, 03:29:29 AM
ac,
  I ran the smf repairsettings.php file, and it allowed me to repair
about 5 instances of incorrect http://wholives.com/wholives/forum/file.htm
But this did not correct the problem.  I think the problem is with rewrite
or something.  Keep in mind that wholives.com is a subdomain of doctoreast.com,
and so it's really tricky.
pe
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: admin on May 01, 2007, 02:17:05 AM
In response to some comments made regarding the use of mod_rewrite to save us from creating vhosts.

This system was designed to service one domain per account.  (That is, one set of files per account)

We do have 2 subdomain slots available that can be used upon request to point domains to alternative directories or to setup subdomains to do the same.  [Using one of these slots are the only way to make redirects for files that are directories work properly]

The .htaccess mod_rewrite workaround was developed by users as a way to allow hosting of multiple domains/websites in one account.

Our commercial hosting products already allow you to create separate vhosts for separate domains if you wish.  The FreePgs service was not intended to host more than one website per account.  (If you need this ability, please check out the monthly plans at LVCS.NET)

Thank you,
FreePgs.com Admin
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on May 01, 2007, 08:20:17 AM

For the record, there is a slight discrepancy as to
the recommended root htaccess format code.

Look at the  \/ missing on the second code. Which
is it? 

First recommendation was:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?EXAMPLE.NET$
RewriteRule ^(DIRECTORY\/)?(.*)$ DIRECTORY/$2 [L]


Now Admin has me using:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?EXAMPLE.NET$
RewriteRule ^(DIRECTORY/)?(.*)$ DIRECTORY/$2 [L]


Thanks,
Doc
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: admin on May 01, 2007, 08:57:23 PM
Either should work.  The "/" should not need to be escaped at the end of the entry.  (Meaning the DIRECTORY/ should work) but they are equivalent to each other. ("\" is used to escape characters from their special meaning)

Thank you,
FreePgs.com Admin
Title: Re: '07: Multiple Domain Names using .htaccess
Post by: doctoreast on May 02, 2007, 08:35:57 AM
Admin,

  Thank you for allowing the rewrite, neat trick, and it's nice to
be able to play with my domain names like this.
    I had something strange going on the other day, where
one domain kept jumping to my root folder, which was
another domain.  Well, what I did was to leave my root empty,
not a domain name, just domain subfolders, and it's now smooth
as glass...  This may also allow me to use one set of images/scripts,
for all domains?... I'm playing with that now.
   Again, thanks for this great service; and great support.
Doc