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 ------------------------------------------------------------------------------------ ...
随机推荐
- 走向DBA[MSSQL篇] - 从SQL语句的角度提高数据库的访问性能(转)
最近公司来一个非常虎的DBA,10几年的经验,这里就称之为蔡老师吧,在征得我们蔡老同意的前提下 ,我们来分享一下蔡老给我们带来的宝贵财富,欢迎其他的DBA来拍砖. 目录 1.什么是执行计划?执行计划 ...
- Partitioning by Palindromes
题意: 给定一个字符串,求能分成最小几个回文串 分析:简单dp dp[i]前i个字符能分成的最小数量 dp[i]=min(dp[i],dp[j-1]+1) (j-i 是回文串) #include &l ...
- HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632
http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...
- 【数据结构和算法】 O(1)时间取得栈中的最大 / 最小元素值
常数时间取得栈中的元素最大值和最小值,我们可以想到当push的时候比较一下,如果待push元素值小于栈顶元素,则更新min值,最大值亦然. 这样有个问题就是当pop的时候,就没了最大最小值. 于是上网 ...
- 宏定义(#define)和常量(const)的区别
最近开始准备一边做实验室的研究,一边记录一些遇到的编程中的小知识点.今天在测试对矩阵进行SVD分解时,需要定义矩阵的行和列的大小,我习惯性的用宏定义来定义了这两个变量,在运行的时候,就开始思考宏定义和 ...
- apache环境下配置服务器支持https
SSL加密的意义在于保护服务器到客户端的信息或者是客户端到服务器的信息不被监听和篡改. 现在一些主流的网站都已经是通过 https访问了,搜索引擎对此类网站的收录也不存在问题了. 具体的配置流程大概是 ...
- [Hive - LanguageManual] DML: Load, Insert, Update, Delete
LanguageManual DML Hive Data Manipulation Language Hive Data Manipulation Language Loading files int ...
- HDU-4727 The Number Off of FFF 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727 水题.. //STATUS:C++_AC_187MS_288KB #include <fu ...
- libpcap/wwinpcap
winpcap(windows packet capture)是windows平台下一个免费,公共的网络访问系统.开发winpcap这个项目的目的在于为win32应用程序提供访问网络底层的能力.win ...
- ocp 1Z0-047 1-60题解析
1. You need to load information about new customers from the NEW_CUST table into the tables CUST and ...