wordpress 采用多站点模式时, 想要访问根目录的文件都是 404

wordpress 采用多站点模式时, 想要访问根目录的文件都是 404


正在查看 7 个帖子:1-7 (共 7 个帖子)
  • 作者
    帖子
  • 364501079
    • 文章数量: 52
    @364501079
    楼主

    比如我的网站时多站点的。但是我平时会有校验的txt文件放在根目录。但是一直无法访问
    比如https://www.xxxx.com/asdasd.txt  一直无法访问。有什么解决方法


    我的伪静态是
    location / {
    index index.html index.htm index.php l.php;
    autoindex off;
    }
    location ~ \.php(.*)$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    include fastcgi_params;
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;
    if (-f $request_filename){
    set $rule_2 1;
    }
    if (-d $request_filename){
    set $rule_2 1;
    }
    if ($rule_2 = “1”){
    #ignored: “-” thing used or unknown variable in regex/rew
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
    rewrite /. /index.php last;

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    需要你把服务器的各项配置参数贴下,看上面像是 Nginx 的规则,但你这规则看着咋这么乱。

    贴下面的参数信息

    364501079
    • 文章数量: 52
    @364501079
    楼主

    系统: CentOS Linux 7.4.1708 (Core)
    php 用的是7.2以上


    <div id=”gtx-trans” style=”position: absolute; left: -78px; top: -9.6px;”>
    <div class=”gtx-trans-icon”></div>
    </div>

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    Nginx 伪静态的规则

    rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
    if (!-e $request_filename){
    	rewrite ^.+?(/wp-.*) $1 last;
    	rewrite ^.+?(/.*\.php)$ $1 last;
    	rewrite ^ /index.php last;
    }

    如果遇到子站采用 wp- 开头的链接 404 的话就把上面的规则 rewrite ^.+?(/wp-.*),改成 rewrite ^.+?(/.*) 一般不用改。

    然后 Nginx 虚拟主机的配置文件参考

    server
    {
        listen 80;
        server_name weixiaoduo.com www.weixiaoduo.com;
        index index.php index.html index.htm default.php default.htm default.html;
        root /www/wwwroot/weixiaoduo.com;
        
        #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
        #error_page 404/404.html;
        #SSL-END
        
        #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
        #error_page 404 /404.html;
        #error_page 502 /502.html;
        #ERROR-PAGE-END
        
        #PHP-INFO-START  PHP引用配置,可以注释或修改
        include enable-php-73.conf;
        #PHP-INFO-END
        
        #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
        include /www/server/panel/vhost/rewrite/weixiaoduo.com.conf;
        #REWRITE-END
        
        #禁止访问的文件或目录
        location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
        {
            return 404;
        }
        
        #一键申请SSL证书验证目录相关设置
        location ~ \.well-known{
            allow all;
        }
        
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
            error_log off;
            access_log /dev/null;
        }
        
        location ~ .*\.(js|css)?$
        {
            expires      12h;
            error_log off;
            access_log /dev/null; 
        }
        access_log  /www/wwwlogs/weixiaoduo.com.log;
        error_log  /www/wwwlogs/weixiaoduo.com.error.log;
    }

    看清楚上面的各项软件版本参数再改。

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    上面操作的覆盖操作前,自行备份下你的旧规则,免得到时候啥问题没有参考的。

    364501079
    • 文章数量: 52
    @364501079
    楼主

    但是用这个伪静态时,api的调用就无法使用了

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    翻你以前的帖子,有讨论过这个问题。

正在查看 7 个帖子:1-7 (共 7 个帖子)
  • 哎呀,回复话题必需登录。

未找到对应子版块?请直接在 [疑难杂症] 版块中发帖提问。

收藏纪念品


有奖活动

参与论坛社区问答,有机会获赠文派瓦普(Wapuu.com)手办模型。

话题信息

商业系统