How to make same Website as multiple subdomain - php

I need a big big help from you guys.
I have a website, say for an example www.abc.com. My Client need to change this entire website for three subdomains to address three countries.all three should be identical copies.
Example:
http://us.abc.com
http://in.abc.com
All the three subdomains should work like the main website.
I thought to copy all my site folders to copy into three folders as US, IN, FR and uploading it into the host and direct those folders to subdomains. Since this will create large number of files and folders I'll hesitate to do this.
Is this method is good or how should I overcome the situation... Glad if you can give me a clue. Thanks.

I'm not entirely sure what your question is:
It sounds like you want to use Apache virtual hosts (so the different domain names will be handled by the same server):
http://www.thegeekstuff.com/2011/07/apache-virtual-host/
Of course, you need to have DNS for the three domains point to your web server
You can use Apache configuration to allow the content to be shared or distinguished between the different domains as you wish.
'Hope that helps...
PS:
To answer your original question:
If "http://us.abc.com" and "http://in.abc.com" were different domains with identical content, you wouldn't even need virtual hosts: you could have "abc.com" serve both. But virtual hosts would still be cleaner - in case you wanted to customize one site or the other in the future.
If, on the other hand, you had "http://mysite.abc.com" and "http://mysite.abc.com.in", then you could still serve both sites from the same server. But you must use virtual hosts (because "abc.com" and "abc.com.in" are different domains).
Again - I hope that helps.

Related

Hosting multiple sites on single ip with same code apache

Actually i have one idea regarding web hosting. The thing is i have two different games sites which are hosted on single IP but different codes. The codes are also same. Means i have created 2 databases and 2 FTP's for different websites. The directory structure and the content for both the sites are same.
Here i have one doubt that can i use the same FTP for hosting many websites. Like if i add any content then the added content should be reflected in all the sites. Is it possible through Apache hosted website. Because for every site if i upload the content the usage of disk space takes more for all the websites. Can anyone suggest me?
Please read this blogpost about domain redirection:
http://www.site5.com/blog/apache/htaccess/redirect-to-blog/20090427/
You can create 2 subfolders on your hosting and let .htaccess redirect to the correct folder.

webpage hosted on a server which is pointed by separated domain name, how to hide original server path?

Am sure there's answer on Google but I don't know how to formulate my question:
A php website is hosted on server like this: http://sub.realserver.com/website/index.php
Now I want to link the real domain name to it: http://therealwebsite.com
Problem is, when user visits:http://therealwebsite.com, he will see http://sub.realserver.com/website/index.php as he browse through other pages.
Question is how do I hide this realserver path and replace it with the domain name?
Thanks
edit: the website is hosted on a different server as the real domain name
I presume the domain name and the web site are pointing to the same server.
Although you could use URL rewriting (works with almost all popular web servers), the better solution is to set up your web server to provide that web site for the root of that domain name. How to do that completely depends on what server software you are using.
In apache, you need to create a so-called Virtual Host, configure it to respond to your domain name and set its DocumentRoot directive to the directory where your site is located.
See http://httpd.apache.org/docs/2.0/vhosts/examples.html for an example.
EDIT: I just read your comment. I'm afraid your options are rather limited. The easiest solution, but also the most dirty one, is to create one page with an IFRAME on it, that loads the site from the real server. You could also host a PHP proxy and on the server that hosts your domain name, and let it proxy the site on your
http://sourceforge.net/projects/php-proxy/
(I never used this, nor am I affiliated with this project, but it seems to claim to do what you want.)
I highly recommend though that you update your DNS records on your domain name so that it points to your server that hosts your site, and that you add a virtual host there.
you can do this with asp, there is a good resource on it here -
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

Best practices for hosting marketing/landing pages

I am working on a web application (LAMP stack) that has the code/dependencies for the marketing/landing pages tied in with the application code. The app is hosted on the rackspace cloud.
I've been thinking about whether or not these two sites should be left together, separated on the same server, or hosted on entirely separate servers.
What is common when it comes to hosting marketing/landing pages for web apps? If I need to host the sites on separate ip's or separate servers, what steps will I need to take to have two separate ip's referring to the same base URL. Is it going to be a problem to have a https connection from two seperate ips? If it is, I can likely have all the secure pages on one IP. What would be the correct term used to describe two ips pointing to one base url?
The structure would be:
example.com/landing-page (hosted on x.x.x.1)
example.com/module/app-page (hosted on x.x.x.2)
Any articles or blog posts that discuss this topic?
THANKS!
So, you want the 2 web apps to have access to the same underlying PHP files, like functions, classes, etc? Yeah, that's possible, but not sure if the Rackspace cloud allows this. A dedicated server that you can set 2 IP addresses to with separate virtual hosts will allow this with simple symbolic links and as long as the files are executable by the web user (usually apache)
Hope that answers your question. If you give more details, I may be able to answer your question more accurately.

How can I detect entry to a website by domain?

If I have multiple domain entry points and want to use the same hosting, can I detect by way of PHP or JavaScript what domain that person came though to the hosting website?
ie: I have 3 domains:
www.jackfrost.com
www.holycow.com
www.ohmy.com
Hosting is under www.jackfrost.com.
So if somebody comes in through www.ohmy.com, can I detect that, so I only display content for that entry and different content for a different entry?
(purpose is to keep costs down since the websites are hosted by godaddy)
The best way you can do is to have a look at $_SERVER['HTTP_HOST'] in your PHP script and dispatch your content based on that.
In JavaScript, you can check window.location.hostname for the domain name used.
However, a better way would be to have three different virtual hosts in your webserver configuration - one for each domain you have. This way, even without PHP or any other scripting language, you can have different content for different domains. When using Apache as webserver, you can have a look at the documentation with examples: http://httpd.apache.org/docs/2.2/vhosts/examples.html.
If you do not want or can use name based virtual hosting, you can use only one virtual host, and use mod_rewrite of Apache to internally rewrite requests to other directories based on HTTP_HOST.
If you are using Apache you should set up name-based virtual hosts.
Apache V1
http://httpd.apache.org/docs/1.3/vhosts/name-based.html
Apache V2
http://httpd.apache.org/docs/2.0/vhosts/

Seamlessly direct multiple domains to a single set of PHP files?

I need to direct multiple domains to a single set of (PHP) files. So I point a domain at my server, which then goes to a single index.php file. This index.php file then detects the domain accessing it and returns the appropriate content. I do not want to add domains or set-up sites manually though as this is for a content management service. So it should be a case of a user signing up and it immediately works without me having to manually do anything. The file set must also exist only once, so updates can easily be applied to everyone.
I am currently on shared hosting, but I believe I may need to move to a VPS (running Apache) to achieve this.
How do I go about doing this?
Thanks
Unless I'm missing something about what you're trying to do, a simple CNAME DNS record may work. Just CNAME the new domain to your existing 'main' domain.
However, if you need to know what domain was requested using shared hosting this very well may not work. The catch is you would also have to setup the hosting account to accept requests from the new domain. This seems to be what you're trying to avoid.
If this is the case, you'll need a static IP, and Apache setup to accept wildcard domains and pass them to your application (index.php in this case). You may not need a VPS for this, just a relatively configurable shared hosting account.
Update: To get this working on shared hosting, check out the Apache VirtualHost directive. That's what Apache uses to setup a (wait for it) 'virtual' web server (document root, logs, etc) allowing a single server to host multiple sites. Also checkout Named Based Virtual Hosting, you'll need an account that doesn't do virtual hosting that way.
"So it should be a case of a user signing up and it immediately works without me having to manually do anything"... So you want magic. Anyways domains point to a directory so that is easy just point all domains to the same directory. PHP can examine the full URL so you can use that to select the content.
If you are using something like Joomla you might be able to customize the starting extension. For example all joomla content is stored in tables named jos_XXX.
It should theoretically be modifyable to the base table is domain_com_XXX
Maybe, but you really need to find a good programmer for this, I don't know of any systems that will do this out of the box. Maybe someone else might know of one.

Categories