Map a domain to an existing subdirectory

I have a simple webapp that allows users to create and post their resume online. It is written in php running on a LAMP server. They are currently in their own subdirectory, but I want to write functionality so that they can use their own custom domains. Ex. if they have a current page: http://www.example.com/user1/page1 I would like them to be able to: http://www.customdomain.com/page1 . This will allow them to access the site from any URL and be able to choose which one will be the main one, that is, the one that appears in the address bar all the time.

With my wordpress installations, I am using a plugin to do all the heavy lifting, but this app is entirely in php and wants it to be able to roll my own code. I come across another solution:

/// I think there are a few questions here, the answers to which are still debated on how to create wildcard subdomains like username.tumblr.com, but implementing custom domains like username.com takes a few steps: .username.com needs to be pointed to your server (say with DNS A record). 2.username.com is stored with user data in your database. 3. in your PHP code, you look at the CGI variables for custom domains and take appropriate action. You may also need to configure your server (apache? Iis? Nginx?) To route all port 80 traffic (regardless of domain) to your PHP application. ///

I get # 1, with wordpress installs, which typically have my clients point their domains to my nameservers and then park their domain and then go through a mapping. But I would like to write a script that does most of the heavy lifting, like my wordpress plugin.

thank

+3


source to share


1 answer


That's quite possible. Using LAMP, you want to take a look at the apache httpd.conf file referenced by customdomain.com and see or add an attribute DocumentRoot

like below:

<VirtualHost 1.2.3.4:80>
ServerName customdomain.com
DocumentRoot /user1
</VirtualHost>

      



http://httpd.apache.org/docs/current/mod/core.html#documentroot

0


source







All Articles