不同环境的配置方法如下:
IIS 环境 web.config文件在根目录
(down.php为提示文字页面)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Feed-G" stopProcessing="true">
<match url="^([a-zA-Z0-9]+).zip" ></match>
<action type="Rewrite" url="down.php?d={R:1}" ></action>
</rule>
<rule name="Feed-H" stopProcessing="true">
<match url="^([a-zA-Z0-9]+).rar" ></match>
<action type="Rewrite" url="down.php?d={R:1}" ></action>
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Custom" ></httpErrors>
</system.webServer>
</configuration>
NGINX
(down.php为提示文字页面)
location / {
rewrite ^/([a-z0-9_\-]+)\.zip$ /down.php?d=$1 last;
rewrite ^/([a-z0-9_\-]+)\.rar$ /down.php?d=$1 last;
}
apache 根目录 .htaccess文件
(down.php为提示文字页面)
RewriteEngine On
RewriteRule ^(.+)\.zip$ /down.php?name=$1
RewriteRule ^(.+)\.rar$ /down.php?name=$1
down.php内容可以是纯html文字,也可以是记录下载记录的代码
评论(0)