ThinkPHP nginx 伪静态:
server {
...
location / {
index index.htm index.html index.php;
#如果文件不存在则尝试TP解析
try_files $uri /index.php$uri;
}
location ~ .+\.php($|/) {
root /var/www/html/website;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,
#后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
#加载Nginx默认"服务器环境变量"配置
include fastcgi.conf;
}
}
.htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^app/(\w+)/(.*)$ app/$1/index.php [QSA,PT,L,E=PATH_INFO:$2]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,PT,L,E=PATH_INFO:$1]
</IfModule>
nginx.conf:
if (!-e $request_filename) {
rewrite ^/app/(\w+)/(.*)$ /app/$1/index.php?s=/$2 last;
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
签名:这个人很懒,什么也没有留下!