如下为nginx yii的重写
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
server
{
set
$
host
_path
"/data/site/www.ttlsa.com"
;
access_log
/
data
/
logs
/
nginx
/
www
.
ttlsa
.
com_access
.
log
main
;
server_name
ttlsa
.
com
www
.
ttlsa
.
com
;
root
$
host_path
/
htdocs
;
set
$
yii
_bootstrap
"index.php"
;
# define charset
charset
utf
-
8
;
location
/
{
index
index
.
html
$
yii_bootstrap
;
try
_files
$
uri
$
uri
/
/
$
yii_bootstrap
?
$
args
;
}
# deny access to protected directories
location
~
^
/
(
protected
|
framework
|
themes
/
w
+
/
views
)
{
deny
all
;
}
#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
;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location
~
/
.
{
deny
all
;
access_log
off
;
log_not_found
off
;
}
# php-fpm configuration using socket
location
~
.
php
{
fastcgi_split_path_info
^
(
.
+
.
php
)
(
.
*
)
$
;
#yii catches the calls to unexising PHP files
set
$
fsn
/
$
yii_bootstrap
;
if
(
-
f
$
document_root
$
fastcgi_script_name
)
{
set
$
fsn
$
fastcgi_script_name
;
}
fastcgi_pass
unix
:
/
tmp
/
php5
-
fpm
.
sock
;
# 改成你对应的FastCGI
include
fastcgi_params
;
fastcgi_param
SCRIPT
_FILENAME
$
document_root
$
fsn
;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param
PATH
_INFO
$
fastcgi_path_info
;
fastcgi_param
PATH
_TRANSLATED
$
document_root
$
fsn
;
## Tweak fastcgi buffers, just in case.
fastcgi_buffer
_size
128k
;
fastcgi
_buffers
256
4k
;
fastcgi_busy_buffers
_size
256k
;
fastcgi_temp_file_write
_size
256k
;
}
}
|
收 藏
转载请注明:成长的对话 » yii nginx重写规则