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

适用zend1/2 支持静态cache. apache,nginx.iis6/7

iis7用配置

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
48
49
50
51
52
53
54
55
56
<?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" />
                    </conditions>
                    <action type="Rewrite" url="cached/index.html" />
                </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" />
                    </conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.html" />
                </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" />
                    </conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.xml" />
                </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" />
                    </conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.js" />
                </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" />
                    </conditions>
                    <action type="Rewrite" url="cached/{REQUEST_URI}.json" />
                </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" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^.*$"  ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

nginx 脚本,应用到nginx服务器配置中

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
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插件)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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用重写配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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]

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Proudly powered by WordPress   Premium Style Theme by www.gopiplus.com