ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
> 如发现部署后需增加index.php才可访问,可按ThinkPHP手册或如下文档进行设置 手册地址:https://www.kancloud.cn/manual/thinkphp5_1/353955 ## URL重写 可以通过URL重写隐藏应用的入口文件`index.php`(也可以是其它的入口文件,但URL重写通常只能设置一个入口文件),下面是相关服务器的配置参考: ### \[ Apache \] 1. `httpd.conf`配置文件中加载了`mod_rewrite.so`模块 2. `AllowOverride None`将`None`改为`All` 3. 把下面的内容保存为`.htaccess`文件放到应用入口文件的同级目录下 ~~~ <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule> ~~~ ### \[ IIS \] 如果你的服务器环境支持`ISAPI_Rewrite`的话,可以配置`httpd.ini`文件,添加下面的内容: ~~~ RewriteRule (.*)$ /index\.php\?s=$1 [I] ~~~ 在IIS的高版本下面可以配置`web.Config`,在中间添加`rewrite`节点: ~~~ <rewrite> <rules> <rule name="OrgPage" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" pattern="^(.*)$" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" /> </rule> </rules> </rewrite> ~~~ ### \[ Nginx \] 在Nginx低版本中,是不支持PATHINFO的,但是可以通过在`Nginx.conf`中配置转发规则实现: ~~~ location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } } ~~~