鍍金池/ 問答/PHP  HTML/ ThinkPHP V5.1.18 部署到服務(wù)器上如何去掉public/index

ThinkPHP V5.1.18 部署到服務(wù)器上如何去掉public/index.php也能訪問

ThinkPHP V5.1.18 部署到服務(wù)器上如何去掉public/index.php也能訪問

http://abc.com/public/index.p...

現(xiàn)在需要按如上鏈接鏈接規(guī)則才能訪問,我想要去掉/public/index.php像如下鏈接一樣能訪問

http://abc.com/index/index/index

下面是我的Nginx配置文件,如果我把配置文件里root這一項改成/var/wwwroot/abc/public時,訪問http://abc.com/index.php就報5...,可我已經(jīng)把thinkphp的debug設(shè)為true了,也沒有報詳細錯誤。

server
    {
        listen 80;
        server_name abc.com ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /var/wwwroot/abc;

        location / {
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php?s=/$1 last;
                break;
            }
        }
        
        location ~ [^/]\.php(/|$)
        {
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            include pathinfo.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /var/wwwlogs/abc.com.log;
    }
回答
編輯回答
互擼娃

1.虛擬域名指向/var/wwwroot/abc/public
2.Nginx.conf 配置忽略index:

if (!-e $request_filename){
        rewrite  ^(.*)$  /index.php?s=$1  last;
        break;
     }

3..htaccess如果啟用了,可以試試這個配置

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

4.runtime是否有足夠權(quán)限

如果還不行,可以看看nginx的日志,或者php-fpm日志(打開 php.ini 搜索 display_errors,把 Off 修改為 On就開啟了 php 錯誤提示)

圖示是我的配置圖,可供參考:

clipboard.png

2017年2月9日 06:20