ThinkPHP 隐藏URL中的 index.php
去掉 URL 中的 index.php
通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通过URL重写的方式可以达到这种效果,通常需要服务器开启URL_REWRITE模块才能支持。
例如原来的 URL 为:
http://127.0.0.1/index.php/Index/insert
去掉 index.php 之后变为:
http://127.0.0.1/Index/insert
第一步:更改Apache的httpd.conf 配置文件
1、确认加载了mod_rewrite.so 模块(将如下配置前的 # 号去掉)
LoadModule rewrite_module modules/mod_rewrite.so
2、AllowOverride none 改 AllowOverride ALL
保存httpd.conf,重启Apache服务器;
第二步、添加 .htaccess 文件 Rewrite 规则
如果是Apache则需要在入口文件的同级添加.htaccess文件,内容如下:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$ [QSA,PT,L]
</IfModule>
第三步、更改项目配置文件
编辑项目配置文件 Conf/config.php ,将 URL 模式配置为 2(Rewrite模式):
'URL_MODEL'=>,
至此,各个配置已经完成。保存各配置文件后,重启 Apache 服务器。
内容参考:
http://www.5idev.com/p-thinkphp_htaccess_rewrite.shtml
http://jingyan.baidu.com/article/6079ad0e86ec9928ff86dbe0.html?st=2&os=0&bd_page_type=1&net_type=2
ThinkPHP 隐藏URL中的 index.php的更多相关文章
- ThinkPHP路由去掉隐藏URL中的index.php
官方默认的.htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On ...
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
1.首先修改Apache的httpd.conf文件. 确认httpd.conf配置文件中加载了mod_rewrite.so 模块,加载的方法是去掉mod_rewrite.so前面的注释#号 讲http ...
- ThinkPHP去掉URL中的index.php
我的环境是apache+ubuntu 1,先确认你有没mod_rewrite.so模块 /usr/lib/apache2/modules/mod_rewrite.so 然后在httpd.conf最后一 ...
- ThinkPHP去除url中的index.php
例如你的原路径是 http:.httpd.conf配置文件中加载了mod_rewrite.so模块 .AllowOverride None 讲None改为 All .确保URL_MODEL ...
- ThinkPHP -- 去除URL中的index.php
原路径是 http://localhost/test/index.php/index/add 想获得的地址是 http://localhost/test/index/add 那么如何去掉index.p ...
- ThinkPHP5 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
1.首先修改Apache的httpd.conf文件. 确认httpd.conf配置文件中加载了mod_rewrite.so 模块,加载的方法是去掉mod_rewrite.so前面的注释#号 讲http ...
- TP5隐藏url中的index.php
在public文件夹下,有个.htacess文件,没有则新建一个, 如果已有这个文件,原文件内容如下: <IfModule mod_rewrite.c> Options +FollowSy ...
- thinkPHP隐藏url地址栏中的index.php方法
http://localhost/workSpace/First/index.php/Home/Index/index隐藏上面url中的index.php方法如下: 第一步.删除apache配置文件( ...
- Elasticsearch——禁止Body中的index覆盖Url中的index参数
本篇继续一下Elasticsearch日常使用的技巧翻译. 在Elasticsearch有很多的api支持在body中指定_index等信息,比如mget或者msearch以及bulk. 默认的情况下 ...
随机推荐
- [Linux 性能检测工具]PIDSTAT
PIDSTAT NAME pidstat对linux任务的统计 语法 pidstat [ -C comm ] [ -d ] [ -h ] [ -I ] [ -l ] [ -p { pid [,...] ...
- Greenplum 源码安装教程 —— 以 CentOS 平台为例
Greenplum 源码安装教程 作者:Arthur_Qin 禾众 Greenplum 主体以及orca ( 新一代优化器 ) 的代码以可以从 Github 上下载.如果不打算查看代码,想下载编译好的 ...
- 实现CheckBox的三种选中状态(全选、半选、不选)在GridView中模拟树形的功能
度娘了很多帖子,只说三种状态要用图片替换来做,但没找到有用的例子,被逼自己写了一个 三方控件肯定是很多的,如jstree,可以直接用 由于公司的UDS限制,不能上传图片,只能文字说明了. 就是要在gr ...
- Centos 6.5 Percona 5.6.27 Tokudb 配置
参考 https://www.percona.com/doc/percona-server/5.6/tokudb/tokudb_installation.html # wget https://www ...
- Linux操作系统主机名(hostname)简介
http://www.jb51.net/LINUXjishu/10938.html 摘要:本文是关于Linux操作系统主机名(hostname)的文档,对主要配置文件/etc/hosts进行简要的说明 ...
- Oracle创建用户设置权限
(转:http://www.cnblogs.com/yangy608/archive/2011/08/22/2148893.html) create user TEST identified by & ...
- java基础算法之插入排序
一.插入排序介绍 插入排序(Insertion Sort)是一种简单直观的排序算法.它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入.插入排序在实现上,通 ...
- 原生Ajax
使用原生Ajax 验证用户名是否被注册 创建出注册信息: <h1>注册信息</h1><input type="text" name="txt ...
- LZ77.py
import math from bitarray import bitarray class LZ77Compressor: """ A simplified impl ...
- 1066: [SCOI2007]蜥蜴
1066: [SCOI2007]蜥蜴 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 3545 Solved: 1771[Submit][Status] ...