thinkPHP5新版本 隐藏index.php隐藏index.php 都写好了

public 隐藏

独立主机可以直接把根目录指向public下

虚拟主机可以把public下的index.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>

查看原文

最新文章

  1. js事件代理(委托)
  2. CentOS - FTP server
  3. 创建一个弹出DIV窗口
  4. Java异常处理和设计【转】
  5. Android 一个漂亮的Android日期和时间选择器:DateTimePicker
  6. python判断key是否在字典用in不用has_key
  7. Java - Nested Classes
  8. Linux之档案管理
  9. MySQL数据库备份还原(基于binlog的增量备份)
  10. 自定义web服务器(四)
  11. jQuery封装的表单验证,模仿网易或者腾讯登录的风格
  12. Vijos 1111 小胖的水果 LCS
  13. ansible入门及组件介绍
  14. 十一.keepalived高可用服务实践部署
  15. dataTable使用方法
  16. nginx的https代理http配置
  17. python装饰器@用法
  18. Python学习-22.Python中的函数——type
  19. java-接口和抽象类的联系和区别。
  20. word中手动添加endnote的加载项

热门文章

  1. javascript 之对象-13
  2. 在Windows10搭建WebAssembly开发环境
  3. 「HTML+CSS」--自定义加载动画【008】
  4. C++并发与多线程学习笔记--atomic
  5. [Fundamental of Power Electronics]-PART I-4.开关实现-0 序
  6. BUAA_OS lab4 难点梳理
  7. HelloWorld的命令提示符运行和命名规则
  8. Java(56-64)【IDEA】
  9. 消息中间件rabbitMQ
  10. Java JFR 民间指南 - 事件详解 - jdk.ObjectAllocationSample