Shi Zhuolin's Blog - nginx
type: channel
link: https://www.shizhuolin.com/tag/nginx/
items: zend1/2适用的重写配置(apache,nginx,iis6/7,iirf)

zend1/2适用的重写配置(apache,nginx,iis6/7,iirf)
type: item
date: 2014-03-01T07:41:00+00:00
description: 适用zend1/2 支持静态cache. apache,nginx.iis6/7iis7用配置web.conf<?xml version="1.0" encoding="UTF-8"?> <system.webServer> <match url="^/*$" ignoreCase="false" /> <add input="{DOCUMENT_ROOT}/cached/index.html" matchType="IsFile" /> <action type="Rewrite" url="cached/index.html" /> <match url="^.*$" ignoreCase="false" /> <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.html" matchType="IsFile" /> <action type="Rewrite" url="cached/{REQUEST_URI}.html" /> <match url="^.*$" ignoreCase="false" /> <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.xml" matchType="IsFile" /> <action type="Rewrite" url="cached/{REQUEST_URI}.xml" /> <match url="^.*$" ignoreCase="false" /> <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.js" matchType="IsFile" /> <action type="Rewrite" url="cached/{REQUEST_URI}.js" /> <match url="^.*$" ignoreCase="false" /> <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.json" matchType="IsFile" /> <action type="Rewrite" url="cached/{REQUEST_URI}.json" /> <match url="^.*$" ignoreCase="false" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" /> <action type="None" /> <match url="^.*$" ignoreCase="false" /> <action type="Rewrite" url="index.php" /> </system.webServer> nginx 脚本，应用到nginx服务器配置中nginx.confserver{ access_log off; rewrite_log off; listen 80; server_name domain.name; root /var/www/html/public; index index.html index.php; location / { if (-e $document_root/cached/index.html) { rewrite ^/*$ /cached/index.html break; } if (-e $document_root/cached$request_uri.html) { rewrite ^.*$ /cached$request_uri.html break; } if (-e $document_root/cached$request_uri.xml) { rewrite ^.*$ /cached$request_uri.xml break; } if (-e $document_root/cached$request_uri.json) { rewrite ^.*$ /cached$request_uri.json break; } if (-e $document_root/cached$request_uri.js) { rewrite ^.*$ /cached$request_uri.js break; } if (!-e $request_filename) { rewrite ^.*$ /index.php; } } location ~ \.php$ { fastcgi_pass unix:/tmp/php-fpm.socket; fas…