duanran6441 2013-02-07 05:32
浏览 119

将域映射到现有子目录

I have a simple webapp that allows users to create and host their resumes online. It is written in php running on a LAMP server. They currently reside in their own subdirectory but I want to write in functionality to allow them to use their own custom domains. Ex. if they have a current page of: http://www.example.com/user1/page1 I would like them to be able to have: http://www.customdomain.com/page1. This would let them access the site from either URL and be able to choose which one would be the primary domain, that is the one that shows up in the address bar all the time.

With my wordpress installs I use a plugin to do all the heavy lifting but this app is completely in php and want to be able to roll my own code. I come across another with the solution of:

/// I think there are a few questions here, the answers so far address how to create the wildcard subdomains like username.tumblr.com, but to implement custom domains like username.com will require several steps: 1. username.com needs to point to your server (say with a DNS A record). 2. username.com is stored with the user data in your database. 3. in your PHP code you watch 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 app. ///

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

Thanks

  • 写回答

1条回答 默认 最新

  • douqiang6036 2015-01-19 22:15
    关注

    This is perfectly possible. Using LAMP you'd want to take a look at the apache httpd.conf file where customdomain.com is referenced and take a look at, or add a DocumentRoot attribute as below:

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

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

    评论

报告相同问题?

悬赏问题

  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan