Apache - hosts file point subdomain - apache

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?

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!

Correct Apache Configuration And Htaccess

I've just reset my Ubuntu 14.04 LAMP server hosted with digital ocean. Could someone tell me the 'proper' way to do server configuration. My goal is to do everything as clean as possible (and hopefully well structured).
I intend on using the server mainly for programming and data analytics, however I do plan on hosting my website in /var/www/html. I also plan on using letsencrypt/certbot to get an easy SSL. With this in mind, these are the main goals I would like to accomplish:
1) Redirect the website to ALWAYS be served through https AND www.
2) Enable HSTS for the entire website.
3) Enable clean url's (remove .php extensions and what not).
Since I would like all of these properties to be used across the entire website, should the configuration be done inside of the /etc/apache2/ folder? Or should it be done inside of .htaccess?
And if it should be done inside of apache2 configuration, which file should I add it to? And finally, how exactly should it be added? (for example vhost 80/443, inside of a mod_something section, etc).
Thank you in advance, I would appreciate and consider any advice about Apache and htaccess!

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.

IIS virtual directory home different than 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!

Webserver cant find its own webaddress

I got a Windows Server 2008, with 2 webapplications running on it, www.myapp.com and update.myapp.com. When Im not on my webserver, the urls works fine, but they doesnt work when my server request those urls. However, localhost works on webserver. The server can also reach other websites just fine.
Now I need www.myapp.com to be able to talk to update.myapp.com, but since my server doesnt want to talk to itself, it wont work. How can I solve this?
Strange. This is hacky, but I'd edit your hosts file to point those two domains to localhost (127.0.0.1).
The windows hosts file should be in :
%SystemRoot%\system32\drivers\etc\
There should be an example in there. Just add two lines for those two addresses.