thinkPHP5新版本 隐藏index.php隐藏index.php 都写好了public 隐藏独立主机可以直接把根目录指向public下虚拟主机可以把public下的index.php放到根目录php //public下原有index.php // 定义应用目录 define(‘APP...
                
    thinkPHP5新版本 隐藏index.php隐藏index.php 都写好了
public 隐藏
独立主机可以直接把根目录指向public下
虚拟主机可以把public下的index.php放到根目录php //public下原有index.php // 定义应用目录 define(‘APP_PATH‘, __DIR__ . ‘/../application/‘); // 加载框架引导文件 require __DIR__ . ‘/../thinkphp/start.php‘;
        //放到根目录下的index.php
// 定义应用目录
define('APP_PATH', __DIR__ . '/application/');
// 加载框架引导文件
require __DIR__ . '/thinkphp/start.php';
    
    Apache下隐藏index.php
tp5都给写好了.htaccess文件 index.php都给隐藏掉了
如果是index.php移到根目录了只需要把.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下隐藏
有的主机后台有URL Rewrite直接写规则就可以了
没有直接在根目录创建web.config
        //其中代码
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WPurls" enabled="true" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="index.html" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>
    
    查看原文
原文:https://www.cnblogs.com/yulongcode/p/12172586.html
本文标题为:ThinkPHP5 Apache / IIs环境下 URL重写
				
        
 
            
        - 阿里云ECS排查CPU数据分析 2022-10-06
 - CentOS_mini下安装docker 之 安装docker CE 2023-09-23
 - KVM虚拟化Linux Bridge环境部署的方法步骤 2023-07-11
 - IIS搭建ftp服务器的详细教程 2022-11-15
 - 【转载】CentOS安装Tomcat 2023-09-24
 - nginx中封禁ip和允许内网ip访问的实现示例 2022-09-23
 - 教你在docker 中搭建 PHP8 + Apache 环境的过程 2022-10-06
 - CentOS7安装GlusterFS集群的全过程 2022-10-10
 - 解决:apache24 安装后闪退和配置端口映射和连接超时设置 2023-09-11
 - 利用Docker 运行 python 简单程序 2022-10-16
 
						
						
						
						
						
				
				
				
				