ThinkPHP5 Apache / IIs环境下 URL重写
2024-10-21 09:33:21
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>
最新文章
- js事件代理(委托)
- CentOS - FTP server
- 创建一个弹出DIV窗口
- Java异常处理和设计【转】
- Android 一个漂亮的Android日期和时间选择器:DateTimePicker
- python判断key是否在字典用in不用has_key
- Java - Nested Classes
- Linux之档案管理
- MySQL数据库备份还原(基于binlog的增量备份)
- 自定义web服务器(四)
- jQuery封装的表单验证,模仿网易或者腾讯登录的风格
- Vijos 1111 小胖的水果 LCS
- ansible入门及组件介绍
- 十一.keepalived高可用服务实践部署
- dataTable使用方法
- nginx的https代理http配置
- python装饰器@用法
- Python学习-22.Python中的函数——type
- java-接口和抽象类的联系和区别。
- word中手动添加endnote的加载项
热门文章
- javascript 之对象-13
- 在Windows10搭建WebAssembly开发环境
- 「HTML+CSS」--自定义加载动画【008】
- C++并发与多线程学习笔记--atomic
- [Fundamental of Power Electronics]-PART I-4.开关实现-0 序
- BUAA_OS lab4 难点梳理
- HelloWorld的命令提示符运行和命名规则
- Java(56-64)【IDEA】
- 消息中间件rabbitMQ
- Java JFR 民间指南 - 事件详解 - jdk.ObjectAllocationSample