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
随机推荐
- Unity3D调用android方法(非插件方式)
关于Unity3Dproject与androidproject的转换与合并,请參考我的另外一篇博客.假设你对Unity3Dproject增加到androidproject的过程不熟悉.也请先看完以下这 ...
- SpringMVC+Spring+mybatis项目从零开始--分布式项目结构搭建
转载出处: SpringMVC+Spring+mybatis+Redis项目从零开始--分布式项目结构搭建 /** 本文为博主原创文章,如转载请附链接. **/ SSM框架web项目从零开始--分布式 ...
- Nginx+Tomcat+Memcached 实现集群部署时Session共享
Nginx+Tomcat+Memcached 实现集群部署时Session共享 一.简介 我们系统经常要保存用户登录信息,有Cookie和Session机制,Cookie客户端保存用户信息,Sessi ...
- MongoDB副本集配置系列一:安装MongoDB
1:下载MongoDB 2.6版本 https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.9.zip 2:解压 tar ...
- pyDes介绍
使用参数如下(拷贝自上述提供的地址): Class initialization -------------------- pyDes.des(key, [mode], [IV], [pad], [p ...
- 搭建ssm框架项目基本原理和主要的配置文件小结
原文地址:https://blog.csdn.net/baidu_32739019/article/details/73928040 1.springmvc是spring框架的一个模块,springm ...
- loadrunner 脚本开发-参数化之将内容保存为参数、参数数组及参数值获取
转自:http://blog.sina.com.cn/s/blog_13cc013b50102v49c.html(查看原文) 在VuGen中默认使用{}的字符串称为参数 注意:参数必须在双引号中才能用 ...
- 【laravel5.4】安装指定版本的predis 和 处理laravel5.*安装使用Redis以及解决Class 'Predis\Client' not found和Fatal error: Non-static method Redis::set() cannot be called statically错误
(predis下载地址:https://packagist.org/packages/predis/predis) 1.cmoposer 命令行: php composer require predi ...
- Go map中一个很重要的特性
先看一段代码: func main() { m := make(map[int]string) m[1] = "a" m[2] = "b" m[3] = &qu ...
- Instagram/IGListKit 实践谈(UICollectionView框架)
简单介绍 IGListKit是Instagram推出的新的UICollectionView框架,使用数据驱动,旨在创造一个更快更灵活的列表控件. github地址:https://github.com ...