开发者

Domain Mapping with php?

开发者 https://www.devze.com 2023-02-15 01:40 出处:网络
today im playing with domains with php, example www.wordpress.com is our main site www.friend1.com is my new domain

today im playing with domains with php,

example

www.wordpress.com is our main site
www.friend1.com is my new domain
www.friend2.com is my new domain
www.friend3.com is my new domain

to

www.friend1.com the same as www.wordpress.com/profile/friend1 ?
www.friend2.com the same as www.wordpress.com/profile/friend3 ?
www.friend3.com the same as www.wordpress.com/profile/friend2 ?

how do wordpress, etc do things like that? are they doing that in the server side ? or there is a way doing stuff like that in php?

*edit if you still dont get it,

heres a example. lets say you have a friend deviant开发者_StackOverflow社区art id at myfrienddeviantartid.devaintart.com and lets say you are the admin on deviantart. you want to make a addon service that your friend can park his own domain into deviantart.com.


This is traditionally done using mod_rewrite inside Apache's configuration. It remaps URLs.


  • For apache http server, it uses ProxyPassReverse directive from mod_proxy or directives from mod_rewrite

The directive ProxyPassReverse lets Apache adjust the URL in the Location header on HTTP redirect responses. For instance this is essential when Apache is used as a reverse proxy to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.

Suppose the local server has address http://wibble.org/; then

ProxyPass /mirror/foo/ http://foo.com/
ProxyPassReverse /mirror/foo/ http://foo.com/

will not only cause a local request for the http://wibble.org/mirror/foo/bar to be internally converted into a proxy request to http://foo.com/bar (the functionality ProxyPass provides here). It also takes care of redirects the server foo.com sends: when http://foo.com/bar is redirected by him to http://foo.com/quux Apache adjusts this to http://wibble.org/mirror/foo/quux before forwarding the HTTP redirect response to the client.

  • For MS(R) IIS use Re-Write Module:

Easily replace Web application URLs to produce user and search engine >friendly results. URL Rewrite permits Web administrators to easily replace the URLs >generated by a Web application in the response HTML with a more user friendly and search engine friendly equivalent. Links can be modified in the HTML markup generated by a Web application behind a reverse proxy. URL Rewrite makes things easier for outbound response content and headers rewriting with outbound rewrite rules that work with HTTP request and response headers and with IIS server variables.

Additionaly, you must make sure that subdomain is setup with DNS provider to pass all requests to main.

DNS Record Sample:

NAME                    TYPE   VALUE
--------------------------------------------------
exampleXYZ.com.         CNAME  example.com.
example.com.            A      192.0.2.23

Ref:

  1. https://en.wikipedia.org/wiki/CNAME_record

  2. http://www.akadia.com/services/apache_redirect.html

  3. http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

  4. http://www.iis.net/downloads/microsoft/url-rewrite

0

精彩评论

暂无评论...
验证码 换一张
取 消