zend1/2适用的重写配置(apache,nginx,iis6/7,iirf)

本文提供了适用于zend1/2框架的重写配置,旨在支持静态缓存。包括针对apache、nginx和IIS6/7的配置示例,确保静态资源如html、xml、js和json文件的正确处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

适用zend1/2 支持静态cache. apache,nginx.iis6/7iis7用配置
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system webserver="">
        <rewrite>
            <rules>
                <rule name="Static Rule 1" stopprocessing="true">
                    <match url="^/*$" ignorecase="false">
                    <conditions logicalgrouping="MatchAll">
                        <add input="{DOCUMENT_ROOT}/cached/index.html" matchtype="IsFile">
                    </add></conditions>
                    <action type="Rewrite" url="cached/index.html">
                </action></match></rule>
                <rule name="Static Rule 2" stopprocessing="true">
                    <match url="^.*$" ignorecase="false">
                    <conditions logicalgrouping="MatchAll">
                        <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.html" matchtype="IsFile">
                    </add></conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.html">
                </action></match></rule>
                <rule name="Static Rule 3" stopprocessing="true">
                    <match url="^.*$" ignorecase="false">
                    <conditions logicalgrouping="MatchAll">
                        <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.xml" matchtype="IsFile">
                    </add></conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.xml">
                </action></match></rule>
                <rule name="Static Rule 4" stopprocessing="true">
                    <match url="^.*$" ignorecase="false">
                    <conditions logicalgrouping="MatchAll">
                        <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.js" matchtype="IsFile">
                    </add></conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.js">
                </action></match></rule>
                <rule name="Static Rule 5" stopprocessing="true">
                    <match url="^.*$" ignorecase="false">
                    <conditions logicalgrouping="MatchAll">
                        <add input="{DOCUMENT_ROOT}/cached{REQUEST_URI}.json" matchtype="IsFile">
                    </add></conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.json">
                </action></match></rule>
                <rule name="Imported Rule 1" stopprocessing="true">
                    <match url="^.*$" ignorecase="false">
                    <conditions logicalgrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchtype="IsFile">
                        <add input="{REQUEST_FILENAME}" matchtype="IsDirectory">
                    </add></add></conditions>
                    <action type="None">
                </action></match></rule>
                <rule name="Imported Rule 2" stopprocessing="true">
                    <match url="^.*$" ignorecase="false">
                    <action type="Rewrite" url="index.php">
                </action></match></rule>
            </rules>
        </rewrite>
    
</system></configuration>
nginx 脚本,应用到nginx服务器配置中
server{
        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;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
IIRF(适用iis6 iirf插件)
RewriteEngine ON

RewriteCond %{APPL_PHYSICAL_PATH}cached/index.html -f
RewriteRule ^/*$ /cached/index.html [L]

RewriteCond %{APPL_PHYSICAL_PATH}cached%{REQUEST_URI}.html -f
RewriteRule ^.*$ /cached%{REQUEST_URI}.html [L]

RewriteCond %{APPL_PHYSICAL_PATH}cached%{REQUEST_URI}.xml -f
RewriteRule ^.*$ /cached%{REQUEST_URI}.xml [L]

RewriteCond %{APPL_PHYSICAL_PATH}cached%{REQUEST_URI}.js -f
RewriteRule ^.*$ /cached%{REQUEST_URI}.js [L]

RewriteCond %{APPL_PHYSICAL_PATH}cached%{REQUEST_URI}.json -f
RewriteRule ^.*$ /cached%{REQUEST_URI}.json [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,U,L,QSA]
apache用重写配置
RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/cached/index\.html -f
RewriteRule ^/*$ cached/index.html [L]

RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.html -f
RewriteRule ^.*$ cached/%{REQUEST_URI}.html [L]

RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.xml -f
RewriteRule ^.*$ cached/%{REQUEST_URI}.xml [L]

RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.js -f
RewriteRule ^.*$ cached/%{REQUEST_URI}.js [L]

RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.json -f
RewriteRule ^.*$ cached/%{REQUEST_URI}.json [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值