Domain redirect

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Domain redirect

Postby ElfN » 29. December 2010 17:39

I'm trying to set up a local duplicate of the setup I have online so I can do better local testing.

I have a loose partnership with two others and we share a reseller account. We don't host just anyone who needs web space. We have two different kinds of clients, those who use our CMS and those who use Wordpress. Each type of client is set up differently. It is my local setup for the clients using our CMS with which I need help.

The clients who use our CMS do so through an admin panel that . . . okay, explaining it that way is going to be confusing and this whole thing, if you're not using it all the time like we are, is confusing enough.

On our reseller we have a domain that holds all our CMS files. On that individual hosting we have client domains hosted as add-on domains. This gives them an individual presence and gives them access to our stable of content management scripts. When they access the url for their admin, a script checks the url, tests it for site versus host and redirects them as necessary before they sign in. It goes like this.

Code: Select all
if (isset($logout)) {
   unset($logout);
   $_SESSION=array();
   echo "<meta http-equiv='refresh' content='0; url=http://www.$site'>";
}
// The next bit of happiness is to make sure Admin load from the right url when something requiring the editor is loaded.
if (strstr($HTTP_HOST, $site)) {
   echo '<script language="JavaScript">';
   echo 'window.location.href = "http://www.officeelfsites.com/'.$loc_dir.'/Admin.php";';
   echo '</script>';
}
if (isset($_SESSION['siteusid']) && $_SESSION['siteusid'] != $siteid) {
   unset($message);
   $message="<p style='font-weight:bold;'>SiteID is $siteid.  Sessions is:";
   foreach($_SESSION as $key=>$value) {
      $message="<br>$key = $value";
   }
   $message.="<p>Sessions are being unset.";
   $_SESSION=array();
}
if (!isset($_SESSION['siteusid'])) {
   $_SESSION['siteusid']=$siteid;
   $_SESSION['level']="admin";
}



For them to access the cms scripts, they have to be on the oesites domain, in their directory, using their admin. I can comment out the whole admin header script (noted above), but that requires me to change the file before uploading it, and that's what I'm trying to avoid.

How do I "host" officeelfsites.com on my xampp installation? Is there a function for adding a domain or aliasing a domain or something that's going to give me the test bed setup I need?

Thanks.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: Domain redirect

Postby JonB » 29. December 2010 18:42

Umm - did some good research, eh? :lol:

http://foundationphp.com/tutorials/apache22_vhosts.php

http://httpd.apache.org/docs/2.0/vhosts/examples.html

and look in \xampp\apache\conf\extra\httpd-vhosts.conf for an exmaple

:shock:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Domain redirect

Postby ElfN » 29. December 2010 18:58

I've been reading and testing, but haven't hit that magic sweet spot yet. Hopefully what you're providing for links will give me hope.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: Domain redirect

Postby ElfN » 29. December 2010 19:45

Okay, I read and tested both of those. I'm still not getting a productive result.

I update http.conf with DirectoryIndex index.php and got Apache to start.

There are a few of the examples I've tried in httpd-vhosts.conf that cause Apache not to start. With the combos that do work (Apache starts), I get 404 errors when trying to access the site in my browser.

I have not found the combo that gets me to the finish line.

My site file folders are in e:\xampp\htdocs.

My hosts file -

Code: Select all
127.0.0.1 localhost
127.0.0.1   officeelf.com
127.0.0.1 elfnori.com


My virtual server in httpd-vhosts.conf -

Code: Select all
<VirtualHost *:80>
ServerAdmin headelf@officeelf.com
DocumentRoot e:\xampp\htdocs
ServerName officeelfsites.com
ErrorLog e:\xampp\htdocs\error.log
CustomLog e:\xampp\htdocs\cerror.log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin headelf@officeelf.com
DocumentRoot e:\xampp\htdocs\ElfNori
ServerName elfnori.com
ErrorLog e:\xampp\htdocs\error.log
CustomLog e:\xampp\htdocs\cerror.log common
</VirtualHost>


With all of this happiness, with the server restarted, I am getting
Object not found!
Error 404

with this url - http://elfnori.com/Colonix/Admin.php

And just to prove things can get even more screwed up than they are now, when I try to access the site online, I get the content of officeelfsites.com (folders) instead of elfnori.com (files).

I'm getting the sneaking suspicion I'm going to have a much better result if I just rewrite the AdminHeader script to take into account localhost.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: Domain redirect

Postby Sharley » 29. December 2010 20:40

Take a look at this example I created for another member that may help with your vhost issues:
viewtopic.php?f=16&t=43109

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Domain redirect

Postby ElfN » 29. December 2010 21:04

I have got to set this project aside and focus on more critical priorities so I'm backing away from trying to get virtual hosting functional on my local machine. I've stripped out the virtual host setup bits and have established a sound temporary workaround . . . I've stripped my local version of the AdminHeader.php script of anything that checks/redirects based on url. It's purpose is to get my clients to where they can work on their own site yet not access any others.

At some point I'll revisit this and see if I can make it make sense to me. I will bookmark this thread in anticipation of that time.

Thanks.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 64 guests