ThinkPHP6二级目录安装步骤有哪些?

2026-04-02 03:251阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计657个文字,预计阅读时间需要3分钟。

ThinkPHP6二级目录安装步骤有哪些?

由于某些特殊原因,可能需要将ThinkPHP6系统运行在域名二级目录中,例如通过访问 www.51cto.com/oa 来访问oa系统。以下是一些操作步骤供参考(仅供参考):

1. 网站目录:/www/wwwroot/website

2.运行目录:/subdir/public

步骤如下:

1. 确保网站域名已解析到网站目录。

2.修改网站根目录下的`.htaccess`文件(如果存在),添加以下代码:

DirectoryIndex index.php AllowOverride All

3.修改ThinkPHP6系统配置文件`application/extra.php`,设置`app_path`为运行目录路径:

php return [ 'app_path'=> '/subdir/public', ];

4.在浏览器中访问域名二级目录(如 www.51cto.com/oa)即可访问oa系统。

由于某些特殊原因,可能需要将thinkphp6系统运行在域名二级目录中,如通过www.51cto.com/oa访问oa系统,可参考以下操作(仅供参考):

网站目录:/www/wwwroot/website 运行目录:/subdir/public

Nginx配置root目录:root /www/wwwroot/website/subdir/public;

伪静态:

location ~ .*\.(txt|gif|jpg|jpeg|png|bmp|swf|css|js|ico|doc|xls|xlsx|docx|gif|json)$ { #TODO 其它静态文件后缀添加 rewrite ^/subdir/(.*)$ /$1 last; break; } location /subdir/ { index index.php; if (!-e $request_filename){ rewrite ^/subdir/(.*)$ /index.php?s=$1 last; break; } }


ThinkPHP6二级目录安装步骤有哪些?

ThinkPHP源码修改以支持二级目录访问

  1. 修改helper.phpurl方法默认domain参数为:true
  2. 修改Url.phpparseDomain方法返回值为:return $scheme . $domain .'/subdir'

动态生成网址如:

Route::buildUrl($avatar)->suffix(false)->domain(true)->build();

本文共计657个文字,预计阅读时间需要3分钟。

ThinkPHP6二级目录安装步骤有哪些?

由于某些特殊原因,可能需要将ThinkPHP6系统运行在域名二级目录中,例如通过访问 www.51cto.com/oa 来访问oa系统。以下是一些操作步骤供参考(仅供参考):

1. 网站目录:/www/wwwroot/website

2.运行目录:/subdir/public

步骤如下:

1. 确保网站域名已解析到网站目录。

2.修改网站根目录下的`.htaccess`文件(如果存在),添加以下代码:

DirectoryIndex index.php AllowOverride All

3.修改ThinkPHP6系统配置文件`application/extra.php`,设置`app_path`为运行目录路径:

php return [ 'app_path'=> '/subdir/public', ];

4.在浏览器中访问域名二级目录(如 www.51cto.com/oa)即可访问oa系统。

由于某些特殊原因,可能需要将thinkphp6系统运行在域名二级目录中,如通过www.51cto.com/oa访问oa系统,可参考以下操作(仅供参考):

网站目录:/www/wwwroot/website 运行目录:/subdir/public

Nginx配置root目录:root /www/wwwroot/website/subdir/public;

伪静态:

location ~ .*\.(txt|gif|jpg|jpeg|png|bmp|swf|css|js|ico|doc|xls|xlsx|docx|gif|json)$ { #TODO 其它静态文件后缀添加 rewrite ^/subdir/(.*)$ /$1 last; break; } location /subdir/ { index index.php; if (!-e $request_filename){ rewrite ^/subdir/(.*)$ /index.php?s=$1 last; break; } }


ThinkPHP6二级目录安装步骤有哪些?

ThinkPHP源码修改以支持二级目录访问

  1. 修改helper.phpurl方法默认domain参数为:true
  2. 修改Url.phpparseDomain方法返回值为:return $scheme . $domain .'/subdir'

动态生成网址如:

Route::buildUrl($avatar)->suffix(false)->domain(true)->build();