Heim  >  Artikel  >  Backend-Entwicklung  >  php怎么让不同的域名指向同一个页面

php怎么让不同的域名指向同一个页面

WBOY
WBOYOriginal
2016-08-18 09:16:311165Durchsuche

本人是一名前端,接触后台不长时间,今天看到有两个顶级域名,输入域名打开的都是同一个页面,但是地址栏却没有变化,不知道这是什么原理,哪位知道?

回复内容:

本人是一名前端,接触后台不长时间,今天看到有两个顶级域名,输入域名打开的都是同一个页面,但是地址栏却没有变化,不知道这是什么原理,哪位知道?

楼上说得都对的, 两个域名指向同一个页面(应用), 除了在服务器配置以外, 还可以设置CNAME解析, 使其不同的域名访问具有相同的效果

nginx的服务配置

<code class="php">server {

    listen       80;
    # 这里使两个不同的域名具有同样的访问效果
    server_name  www.baidu.com www.godruoyi.com;
    
    charset utf-8;
    root   /data/admin_www/www;

    location / {
        index  index.html index.htm index.php;
        if (!-e $request_filename) {
            rewrite ^/(.*) /index.php?$1 last;
        }
    }
    
    location ~ \.php$ {
        fastcgi_pass    unix:/dev/shm/php-fpm.sock;
        #fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME  $request_filename;
        include         fastcgi_params;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        proxy_pass http://$host/error/index; 
    }
}

</code>

服务器配置的,配置不同的域名指向同一个项目就可以了

这和PHP没有关系啊
在域名的管理控制台把两个域名解析到同一个服务器而已

服务器控制端可以自定义

两个域名绑定了同一ip

这个是在服务器配置的,跟项目部署一样,支持域名多对一

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn