ThinkPHP在Apache和Nginx下去除index.php方法
由于项目需要,用ThinkPHP开发的程序链接要去除index.php下面说下如何解决。
一.Nginx方法
由于nginx不支持PATH_INFO,所以需要进入linux终端找到nginx 的配置文件nginx.conf添加如下代码:
location /
{ if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=$ last; break;
}
}
使用如下:
server
{ listen ;
server_name www.blhere.com; index index.html index.htm index.php;
root /data/htdocs/wwwroot/www; #limit_conn crawler ; location /
{ if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=$ last; break;
}
} location ~ .*\.(php|php5)?$
{ #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fcgi.conf;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 1h;
}
}
二.apache
[ Apache ]
httpd.conf配置文件中加载了mod_rewrite.so模块AllowOverride None将None改为All- 把下面的内容保存为
.htaccess文件放到应用入口文件的同级目录下<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$ [QSA,PT,L]
</IfModule>
有时候index.php后面加加? ---->index.php?/
参考:https://www.kancloud.cn/manual/thinkphp5_1/353955
转: https://www.cnblogs.com/behindman/p/8667731.html
ThinkPHP在Apache和Nginx下去除index.php方法的更多相关文章
- 通过apache,和nginx模块去除html中的空格和tab
最近一个项目中,合作方要求去除html中的空格,不想改代码,所以百度了一下通过apache,和nginx模块去除html中的空格和tab的方案,下面记录下来: 一.nginx nginx可以通过mod ...
- Apache和Nginx下禁止访问特定的目录或文件
大家是否测试Apache做了目录禁止浏览后,目录下面的txt文件还是可以显示里面的内容的.例如:http://www.domain.com/test/此访问会报403错误,但是如果test下有很多tx ...
- Apache和Nginx配置支持苹果ATS方法
什么是ATS功能? ATS是iOS9和OS X El Capitan的一个新特性.开启该功能后,ATS对使用NSURLConnection, CFURL或NSURLSession 等APIs 进行的网 ...
- nginx配置thinkphp项目(nginx下去掉index.php)
server { listen 80; server_name xxxxx; root "/www/public"; location / { index index.html i ...
- Apache 和 Nginx 下的 URL 重写
URL 重写和重定向 URL 重写是将页面映射到本站另一页面, 而重定向则是将页面映射到另一主机(域名). 其中临时重定向(R=302)和永久重定向(R=301)都是亲搜索引擎的, 是 SEO 的重要 ...
- Apache 和 Nginx 下绑定域名
Apache 方法一 参考:链接 版本:2.3 配置文件位置:/usr/share/doc/httpd/httpd-vhosts.conf 添加域名和站点信息: vim /usr/share/doc/ ...
- thinkphp 5.0 在appache下隐藏index.php入口代码
一.在appache的配置文件httpd.conf中开启rewrite_module 二.启用.htaccess的配置 启用.htaccess,需要修改httpd.conf,启用AllowOverri ...
- Nginx下隐藏index.php
在用NGINX搭建web网站时遇到一个问题,那就是除了网站的首页能够正常打开,其他的子网站都打不开,显示找不到文件.但是如果你在网址后面加上index.php,子网站就又可以打开了.那么我们怎么才能不 ...
- thinkphp在wamp 配置去掉url中index.php方法
http://blog.csdn.net/youmypig/article/details/45008971
随机推荐
- Spark的运行模式(2)--Yarn-Cluster和Yarn-Client
3. Yarn-Cluster Yarn是一种统一资源管理机制,可以在上面运行多种计算框架.Spark on Yarn模式分为两种:Yarn-Cluster和Yarn-Client,前者Driver运 ...
- Rabbit mq订阅方式获取消息并可设置持久化
Rabbit 通过方式获取消息:订阅方式事实上是向queue注冊consumer,通过rpc向queue server发送注冊consumer的消息.rabbitMQ Server在收到消息后,依据消 ...
- string int 类型转换
string int 类型转换 (int) 此方法不适用于将string 转换为int 只能转换数值类型为int 而不能转换引用类型 不会四舍五入 直接去掉小数位 Conver.ToInt() 会 ...
- dpkg 小记
dpkg 安装 dpkg -i to-be-install.deb dpkg 删除 dpkg -r name-of-app dpkg -l 查看有哪些包被安装.其中 ii 标记的包是正常的, rc 标 ...
- Java多线程之锁优化策略
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6561264.html 锁的优化策略 编码过程中可采取的锁优化的思路有以下几种: 1:减少锁持有时间 例如:对 ...
- 设置char变量指定位为0或1
int GetBit(char c,int i)//取c的第i位 { ; } void SetBit(char & c,int i, int v)//设置c的第i位为v,v是0或1 { if( ...
- HDU 1069 Monkey and Banana(最大的单调递减序列啊 dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 Problem Description A group of researchers are d ...
- <转>SQL 左外连接,右外连接,全连接,内连接
本文节选自:https://www.cnblogs.com/youzhangjin/archive/2009/05/22/1486982.html 连接条件可在FROM或WHERE子句中指 ...
- [解决问题]selenium.remote.UnreachableBrowserException 异常分析并解决问题
I have a set of automations that work fantastically in Firefox and Chrome, and I'd like to launch an ...
- App 开发步骤
在 iOS 开发中,写一个 App 很容易,但是要写好一个 App,确是要下另一番功夫.首先,我们来看一个 App 的开发要求: 写一个 App,显示出 Spotify 上 Lady Gaga 相关的 ...