ThinkPHP去除url中的index.php
2016-02-17 00:00
691 查看
一、apache服务器
1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉
2.AllowOverride None 讲None改为 All //在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)
<Directory "D:/server/apache/cgi-bin">
AllowOverride none 改 AllowOverride ALL
Options None
Order allow,deny
Allow from all
</Directory>
3.确保URL_MODEL设置为2,在项目的配置文件里写
return Array(
'URL_MODEL' => '2',
);
4 .htaccess文件必须放到跟目录下
这个文件里面加:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
补充:在windows下不能建立以点开头的文件,你可以先随便建立一个文件
然后在DOS在操作 rename xxxx.xxxx .htaccess
转载来源 地址: http://sjolzy.cn/ThinkPHP-remove-the-indexphp-url.html
二、IIS7.5服务器
1、windows 下的地址重写组件基本上都是收费或有限制,从windows server 2008开始官方提供了自己的重写组件,下载地址:http://www.iis.net/downloads/microsoft/url-rewrite。
规则文件要写在网站根目录的web.config中,重写规则可以由.htaccess导入过来,会变成web.config文件,
如上是简单的thinkphp的根目录跟子目录省去index.php的方法,这个实现在apache中简单多了,直接将.htaccess拷贝到根目录及各个子目录就可以了
2.打开官方下载地址,将页面拖到最底下,根据自己的需求选择相应的版本,有语言及32位、64位区分
3.双击同意协议安装
4.安装完成后,开始-管理工具-Internet 信息服务(IIS)管理器 即可找到URL重写模块,双击展开面板,可以看到相应的功能
1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉
2.AllowOverride None 讲None改为 All //在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)
<Directory "D:/server/apache/cgi-bin">
AllowOverride none 改 AllowOverride ALL
Options None
Order allow,deny
Allow from all
</Directory>
3.确保URL_MODEL设置为2,在项目的配置文件里写
return Array(
'URL_MODEL' => '2',
);
4 .htaccess文件必须放到跟目录下
这个文件里面加:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
补充:在windows下不能建立以点开头的文件,你可以先随便建立一个文件
然后在DOS在操作 rename xxxx.xxxx .htaccess
转载来源 地址: http://sjolzy.cn/ThinkPHP-remove-the-indexphp-url.html
二、IIS7.5服务器
1、windows 下的地址重写组件基本上都是收费或有限制,从windows server 2008开始官方提供了自己的重写组件,下载地址:http://www.iis.net/downloads/microsoft/url-rewrite。
规则文件要写在网站根目录的web.config中,重写规则可以由.htaccess导入过来,会变成web.config文件,
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="system" patternSyntax="ECMAScript"> <match url="^.*system/(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/system/index.php?s={R:1}" appendQueryString="true" /> </rule> <rule name="auth" patternSyntax="ECMAScript"> <match url="^.*auth/(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="/auth/index.php?s={R:1}" appendQueryString="true" /> </rule> <rule name="main" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="index.php?s={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> <httpErrors errorMode="Detailed" /> </system.webServer> </configuration>
如上是简单的thinkphp的根目录跟子目录省去index.php的方法,这个实现在apache中简单多了,直接将.htaccess拷贝到根目录及各个子目录就可以了
<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L] </IfModule>
2.打开官方下载地址,将页面拖到最底下,根据自己的需求选择相应的版本,有语言及32位、64位区分
3.双击同意协议安装
4.安装完成后,开始-管理工具-Internet 信息服务(IIS)管理器 即可找到URL重写模块,双击展开面板,可以看到相应的功能
相关文章推荐
- PHP正则表达式
- IIS6切换PHP版本
- THINKPHP日常用到的基础知识
- PHPCMS一些常用调用方法
- phpcms推荐位分组
- PHPCMS URL规则(频道页(栏目页列表页)二级域名,内容页主域名)
- PHPCMS整合UCENTER后登陆问题
- thinkphp主从分离分布式处理
- PHPCMS修改目录
- PHP基本功
- zendstudio破解
- THINKPHP日常注意
- php中类型数组(typed array)
- PHP开发如何实现多线程?
- Atitit.跨平台预定义函数 魔术方法 魔术函数 钩子函数 api兼容性草案 v2 q216 java c# php js.docx
- 深入php面向对象、模式与实践
- php笔记
- _splitpath 或_wsplitpath函数的使用
- PHP邮件群发机实现代码
- 46 个非常有用的 PHP 代码片段