IIS virtual directory home different than Apache - apache

I have a site I developed on a WAMP server in house, and is hosted offsite (presumably on an Apache server). The site was created in the root directory of the WAMP server (C:\wamp\www). I'm now trying to move the in house development site onto a Windows Home Server v1 box (essentially a Server 2003 machine running IIS 6). I'm trying to not have two different versions of the site: one for in house (on IIS), and one for hosting offsite (on Apache).
On the WHS machine, I have a virtual directory <sitename> located at:
c:/inetpub/<sitename>
I can access it on the server at:
Localhost/<sitename>
and from anywhere on the LAN at:
<ServerName>/<sitename>
When I initially wrote the site, I used the ../ declaration for almost every file,
path, directory, and PHP include files. This works fine on the WAMP server and on the
offsite host. But, when I moved the site into the virtual directory <sitename>, it
fails on the IIS server.
All such ../ references point to the server root:
<ServerName>/
rather than site home:
<ServerName>/<sitename>
Presumably, I could move the site into the 'root' directory: c:/inetpub/wwwroot, but
Windows Home Server uses this for something else.
I could change every reference from ../ to ../<sitename>/, but that would mean having 2
different sites to maintain, one for in house and one for offsite.
So, my questions are ...
Is there any way to declare that the virtual directory c:/inetpub/<sitename>
is the home or root directory for this single site? Is there a configuration
in IIS that will do this for this one virtual directory, and not upset the other
sites hosted on this server?
If not;
Can someone point me to some other way to rewrite the site in order
to have it run on both Apache and IIS 6 with no/minimal
alterations for the two different servers?
I have been searching for over a week on this. All of the solutions that I have found are specific to either Apache or IIS, but won't work in both.
Thanks!

Ok, here's a -possible- answer ...
I changed every ../ to a PHP include statement, calling a file I named SiteBase.txt.
On the IIS server, SiteBase.txt consists of a single line: http://<ServerName>/<sitename>/.
On the WAMP server, SiteBase.txt consists of a single line: ../
This way, I only have to change this one file when I move the site from my development server to the production server. A bit Brute-Force, but it seems to be working.
Does anyone see a problem with this?
Thanks!

Related

Use Windows 2016 server with Xampp to host more than 1 website

I have tried all kinds of things, read all answers, and configured the bananas out of it, but I cannot seem to get the following working:
A windows 2016 server with XAMPP, to host more websites than 1.
What have I done:
I have altered the httpd-vhosts.conf as described all over the web with allowing NameVirtualHost, and setting up virtual host with documentroot, servername etc.
I have pointed a domain with the a-record to this server
installed the latest XAMPP release to date
changed the windows hosts file, as described everywhere (127.0.0.1 domainname.com)
What works:
I can get the domain working on my server's browser. When I enter the specific domainname.com it shows the hello world page I made in the specified folder. The domain resolves and shows the page that is in de directory accordingly
Besides that, the localhost of apache is also working, I have 2 sites working, but only on the browser of the server, on the machine itself.
What does not work:
Only 1 thing. when I want to access the domain from any other machine than the server (from outside so to say), it will not work, but when I ping the domain on my home-pc it resolves to the server.
I am at a loss. Been at this for hours, and beginning to question if it is even possible.
Can anyone tell me what I am doing wrong here, or if it is even possible to have more than 1 website to work on XAMPP and resolve form the outside?
Thank you in advance.
It was windows firewall that stopped all inbound connections. I finally figured it out!

Migration to VPS w/Plesk

I had a shared hosting package with 1and1 and I just moved over to their VPS hosting that uses Plesk. I already had the domains moved over the VPS server and I already uploaded all of the files via FTP.
I talked to an agent yesterday and he helped me setup the main page on the website so that it would go to the appropriate root directory. The main website is working properly whenever I go the main domain name, however, whenever I go to website.com/blank or website.com/stuff, I receive a 404 error.
The strange part is that I see the files in Plesk file manager, I just don't know why they are not displaying properly. I didn't change anything in the migration process.
I did not change the code on any of the pages and I have contacted their customer support team a number of times, but they have been unable to resolve the issue.
Can anyone tell me what I should do to make sure that the files are associated with the correct pages?
Have you checked the permission for the files and folder under your domain, this seems to be an issue with either your ownership or permission of the files. And if thats not the problem it could even be your .htaccess file.. make sure you have transferred your .htaccess file as well from old shared hosting to new VPS.

Virtual Directory to navigate to http://localhost/MyWebsite instead of http://localhost:8080

I have deployed an ASP.NET MVC 4 application to a new site I have created in IIS 7.5, which I have bound to port 8080. I can reach it by navigating to http://localhost:8080, but I want to reach it via http://localhost/MyWebsite.
I have added a Virtual Directory under my website, which points to "C:\inetput\wwwroot\MyWebsite\". However, when I navigate to http://localhost/MyWebsite, I am presented with a configuration error:
"It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS."
Here is what my IIS hierarchy looks like (this is a demo since I have no internet access on the server I am working on).
I have two questions:
Why am I getting this error?
Is this the best way to go about achieving what I want? It seems messy to have the list of files and folders underneath the website and then again underneath the Virtual Directory. If there is better practice then please tell!
Virtual Directories cannot execute scripts, reason why you are getting that error. You need to make your MyWebsite folder an Application. Also, you don't necessarily have to create a separate website for your website, you can use the Default Web Site and create an application MyWebsite in there (it might be less confusing maybe?).

Apache - hosts file point subdomain

I have a site I developed locally for a client. They have an existing live site (at www.livesite.com). I want to move the developed site to their server, but I want to test it on their server before it's live.
I thought I'd install the site in a sub directory on their server (www.livesite.com/dev), and then using my hosts file, make my browser think it's viewing the final live URL (www.livesite.com).
However, I've tried various combination of things in my hosts file, and I can't seem to get it to work. The server ip followed by the domain / sub-domain.
I'm running on MAMP on OSX. Anyone have experience with this?

IIS 6 localhost works but nothing else does

If I type localost in IE, it yields "It works!" but I can't seem to locate where exactly that page is picked from.
In c:\InetPub\wwwroot\ nothing exists that points "It works!" page.
I created a test folder inside wwwroot above. I put an aspx file there, it does not work (no file found), then i created a test.htm file, that can not be accessed through localhost/test/test.htm
Anyone knows what is wrong. I never ran IIS on this particular system. I have Windows XP Pro, and IIS6 is installed.
Please help.
I think it will answer it myself. There were two confusion first of all, IIS 5.1 was installed along with IIS 6 (there was a link in Administrative tools) and Apache server as well. Something was probably messing with it before I came. I uninstalled Apache, IIS 6 link (was not supposed to be there in the first place), and even IIS. Fresh installed fixed everything.
Also if you are running into problem like this, get familiar with IIS, how it works. It runs out of Virtual folders and you have to turn these virtual folders into Applications. It is tricky the way Microsoft do it.
In my case probably both the server were using the default port 80 (I am not sure though). I now have both servers intalled (IIS + Apache), with Apache using port 8080.
To test situation like this, do this: create a virtual folder in IIS 5.1, right click on it and turn that folder into application. Put an aspx file in the "actual" location that this virtual folder points to see and then open it in browser using localhost\virtualfolder\myaspx.file. Note that in many case IIS will not pick the default.aspx file automaticaly unless explicity given.