TP5 隐藏入口文件方法

浏览:11240 发布日期:2016/10/23 分类:技术分享 关键字: TP5 隐藏入口文件方法
TP5用了ngnix服务,模板中地址生成用了系统中的 {:url('xxxxx/xxxx')} 方法,隐藏入口文件,个人这样处理了,仅供参考,大枷勿喷。

设置方法两步:
一、vhosts中
****.conf 内容如下:server {
        listen       80;
        server_name  youurl.com;
        index index.html index.htm index.php;
        root /yourpath/;
        location ~ .*\.(php|php5)?$
        {
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_split_path_info ^(.+\.php)(.*)$;     #
                fastcgi_param PATH_INFO $fastcgi_path_info;    #
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;

        }

        location / {
                if (!-e $request_filename) {
                        rewrite  ^(.*)$ /index.php?s=/$1  last;
                        break;
                }
        }
        access_log  /www/log/nginx/access/test.log;
}
设置完后,重启服务:nginx -s reload;

二、修改文件 core\library\think\Url.php
第131行处:
$url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/');
改为: $url = $domain . '/' . ltrim($url, '/');
清理缓存,刷新页面,查看生成地址,为pathinfo模式。

如果有好的办法,欢迎指出。
最佳答案
评论( 相关
后面还有条评论,点击查看>>