puyuetian轻博客伪静态配置
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
}
location ~ ^/.*/.*\.(htm|php)$ {
deny all;
}
Apache:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ index\.php\?s=$1&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/(.*)\.(htm|php)$ - [F]
IIS:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- 重写所有非文件请求到 index.php -->
<rule name="Redirect to Index PHP with Query String">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{QUERY_STRING}" pattern="^(.*)$" />
</conditions>
<action type="Rewrite" url="index.php?s={R:1}&{C:1}" appendQueryString="false" />
</rule>
<!-- 禁止对特定格式路径(包含子目录和.htm|.php扩展名)的访问 -->
<rule name="Block Access to Certain Paths with Query String">
<match url="(.*)/(.*)\.(htm|php)$" />
<conditions>
<add input="{QUERY_STRING}" pattern="^(.*)$" />
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Access is denied." />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>