Heim  >  Artikel  >  Backend-Entwicklung  >  请教一个cms之前加个静态页面的解决办法

请教一个cms之前加个静态页面的解决办法

WBOY
WBOYOriginal
2016-08-04 09:21:291041Durchsuche

服务器:ubuntu 14.04 nginx php5

域名一个:a.com

部署一套类似wordpress的cms系统,但是现在要求在wordpress之前加个静态页面,访问网站的时候首先显示这个静态页面,然后可以点击静态页面上的窗口进入wordpress。

请问如何实现?

回复内容:

服务器:ubuntu 14.04 nginx php5

域名一个:a.com

部署一套类似wordpress的cms系统,但是现在要求在wordpress之前加个静态页面,访问网站的时候首先显示这个静态页面,然后可以点击静态页面上的窗口进入wordpress。

请问如何实现?

假设域名是 a.com 静态页面是 index.html 你可以如下设置:

<code>server {
    listen 80;
    server_name a.com;
    
    root /var/www/a.com;
    
    location / {
        index index.html index.php;
        try_files $uri $uri/ /index.php&is_args&args;
    }
    
    location ~ \.php {
        # php fastcgi 相关配置
    }
    
}</code>

如上配置可以做到,当存在静态页面的时候,即显示静态页面,不存在的时候由 index.php(也就是 wordpress) 来处理,index index.html index.php; 这一行可以在打开 a.com/ 的时候默认访问到index.html(如果这个文件存在),这样配置就完全满足了你的需求。

假设你的域名是a.com,首页是a.com/index.html,把wordpress放在a.com/wordpress/
然后nginx这么配置:

<code>server {
    listen 80;
    server_name a.com;
    
    location / {
        index index.html;
        root 你的静态页面路径;
    }   
    
    location /wordpress {
        index index.php index.html;
        root 你的wordpress路径;
        # 这里放wordpress 和 PHP 的配置
    }
}</code>

把wordpress部署在a.com下面的一个栏目中

不是很明白这个需求,是什么特别的业务需求不允许这个静态页放到wordpress里面吗?

除了楼上的方法
当然还可以用子域名:
你的静态页就放在static.a.com
wordpress 就放在www.a.com

这样应该更有利于SEO

补充一个,WP后台自定义主题,可以设置一个静态首页。
不好意思看错了,并不是WP。

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