yii 隐藏index.php的步骤
Apache
1.开启apache的mod_rewrite模块
去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号
确保<Directory "..."></Directory>中有“AllowOverride All”
2.在项目中的/protected/config/main.php中添加代码:
'components'=>array(
...
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'/',
'<controller:\w+>/<action:\w+>'=>'/',
'manage' => 'content/index',
'manage/<controller:\w+>' => '',
'manage/<controller:\w+>/<action:(update|delete|view)>/<id:\d+>' => '/',
'manage/<controller:\w+>/<action:(create|update|delete|admin|view|changepswd|empty)>' => '/',
'post/<id:\d+>/<title:.*?>'=>'post/view',//此处重要:把post/id/title映射为:post/view/id/title/6
'posts/<tag:.*?>'=>'post/index',//此处重要:把通过“posts/tag”访问的链接变成post/index/tag
),
),
...
),
3.在与index.php文件同级目录下添加文件“.htaccess”,内容如下:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on # if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php
RewriteRule . index.php
NGINX
nginx versions .7 and higher:
server {
set $yii_bootstrap "index.php";
charset utf-;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name mysite.local;
root /path/to/project/web;
index $yii_bootstrap;
access_log /path/to/project/log/access.log main;
error_log /path/to/project/log/error.log;
location / {
# Redirect everything that isn't real file to yii bootstrap file including arguments.
try_files $uri $uri/ /$yii_bootstrap?$args;
}
# uncomment to avoid processing of calls to unexisting static files by yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
When using this configuration, you should set cgi.fix_pathinfo=0 in the php.ini file in order to avoid many unnecessary system stat() calls.
或者nginx versions prior to .7:
server {
listen 80;
server_name .yeegt.com;
charset utf-8;
location /{
root /home/yeegt/yiigt;
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~^/protected/{
deny all;
}
# redirect server error pages to the static page /50x.html
#
error_page 500502503504 /50x.html;
location =/50x.html {
root html;
}
location ~*.(js|jpg|jpeg|gif|png|ico)$ {
root /home/yeegt/yiigt;
expires 356d;
}
location ~\.php$ {
root /home/yeegt/yiigt;
fastcgi_pass 127.0.0.1:9010;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/yeegt/yiigt$fastcgi_script_name;
include fastcgi_params;
set $path_info $request_uri;
if($request_uri ~"^(.*)(\?.*)$"){
set $path_info $1;
}
fastcgi_param PATH_INFO $path_info;
}
}
yii 隐藏index.php的步骤的更多相关文章
- yii 隐藏index.php
首先,开启apache的rewrite模块 去掉rewrite前的#,如下所示 LoadModule rewrite_module modules/mod_rewrite.so 接着,在yii的ind ...
- Yii Framework隐藏index.php文件的步骤
Yii Framework隐藏index.php文件的步骤 作者:feebas 发布于:2012-4-23 13:36 Monday 分类:Yii Framework 1.开启apache的mod_r ...
- yii框架 隐藏index.php 以及美化URL(pathinfo模式访问)
首先我们分步骤来: 安装好 yii 以后 我们看到的url地址如下所示: http://www.3w.com/MyApp/backend/web/index.php?r=site%2Flogin 我 ...
- Yii 1.1 URL两个笔记 同时支持PATH于GET路由和隐藏index.php
同时支持PATH于GET格式路由(修改框架文件 简直坑) framework/web/CUrlManager.php parseUrl方法 第一行判断修改成 if($this->getUrlFo ...
- CI 框架隐藏index.php-ubuntu
和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单.但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步 ...
- url优化|隐藏index.php
隐藏index.php 一.codeigniter codeigniter和许多php框架一样,有个单一入口index.php,从url上看,显得很不友好.通过apache的rewirte,是可以 ...
- Yii2.0简单隐藏index.php文件和模块配置和layout布局配置禁用和日志写入配置
隐藏index.php文件 目的:想去掉浏览器地址栏中的 index.php?r= 这一块. 在/config/web.php中 ’components'=>[] 中添加如下代码: 'u ...
- thinkphp中redirect重定向后隐藏index.php
首先,.htaccess文件要配置好隐藏index.php.系统默认生成的就行. 然后,也是最关键的一部,要在Application/Home/Conf里的config.php文件中增加如下配置: & ...
- tp5 隐藏index.php 邓士鹏
tp5 隐藏index.php ------------------------------------------------------------------------------------ ...
随机推荐
- UI特效--Android利用ViewFlipper实现屏幕切换动画效果
.屏幕切换指的是在同一个Activity内屏幕见的切换,最长见的情况就是在一个FrameLayout内有多个页面,比如一个系统设置页面:一个个性化设置页面.2.介绍ViewFilpper类ViewFl ...
- Visual Studio 2010中创建ASP.Net Web Service
转自:http://blog.csdn.net/xinyaping/article/details/7331375 很多人在论坛里说,在Visual Studio 2010中不能创建“ASP.Net ...
- 如何利用WordPress创建自定义注册表单插件
来源:http://www.ido321.com/1031.html 原文:Creating a Custom WordPress Registration Form Plugin 译文:创建一个定制 ...
- 关于自然常数e的理解
关于自然常数\(e\)的理解 By Z.H. Fu 切问录 ( http://www.fuzihao.org ) 利息增长模型 在上中学学习对数的时候,我们就学到了一个叫做e的东西(\(e\appro ...
- The Services(服务)
datastore和运行时环境的关系就是和一个服务的关系:应用使用API访问一个独立的系统(separate system),这个系统管理应用的所有的独立于应用实例的扩展需求(scaling need ...
- Windows 窗体—— 键盘输入工作原理
方法 注释 PreFilterMessage 此方法在应用程序级截获排队的(也称为已发送的)Windows 消息. PreProcessMessage 此方法在 Windows 消息处理前在窗体和控件 ...
- [现代程序设计]homework-03
Homework-03 队员: 11061193 薛亚杰 11061192 周敏轩 11061190 李孟 材料阅读 我们三个人将以下材料仔细阅读,觉得十分受益.下面是我们的总结和分享: 1)代 ...
- HDU 5802 Windows 10 (贪心+dfs)
Windows 10 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5802 Description Long long ago, there was ...
- [iOS基础控件 - 6.9.4] 抓取网页图片资源
A.需求 1.利用浏览器取得网页的源码 2.解析源码,获取图片地址(这里使用了java的一个库来解析html) 3.获取资源,生成plist目录 B.实现步骤 1.打开一个网页,最好里面是包含了静 ...
- 在C#调用C++的DLL简析(一)——生成非托管dll
经过一晚上的折腾,还是下点决心将些许的心得写下来,以免以后重复劳动. C#与C/C++相 比,前者的优势在于UI,后者的优势在于算法,C++下的指针虽然恶心,若使用得当还是相当方便的,最重要的问题是, ...