標籤: 訪問根目錄檔案
-
作者帖子
-
比如我的網站時多站點的。但是我平時會有校驗的 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;需要你把伺服器的各項配置引數貼下,看上面像是 Nginx 的規則,但你這規則看著咋這麼亂。
貼下面的引數資訊
系統: 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>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; }
看清楚上面的各項軟體版本引數再改。
上面操作的覆蓋操作前,自行備份下你的舊規則,免得到時候啥問題沒有參考的。
但是用這個偽靜態時,api 的呼叫就無法使用了
翻你以前的帖子,有討論過這個問題。
-
作者帖子
- 哎呀,回覆話題必需登入。