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

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

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


两个域名绑定了同一ip


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

nginx的服务配置

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; 
    }
}


服务器控制端可以自定义


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


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


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

【热门文章】
【热门文章】