track 官网追踪伪静态规则,IIS改nginx,apache

折腾记录
799 0

原IIS web.config规则

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

 <system.webServer>
 
  <rewrite>
  
   <rules>
                <clear />
                <rule name="不带www转向www域名规则" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^duxiuexp.com$" ignoreCase="false" />
                    </conditions>
                    <action type="Redirect" url="https://www.duxiuexp.com/{R:1}" redirectType="Found" />
                </rule>
                <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
                </rule>
                <rule name="track" enabled="true" stopProcessing="false">
                    <match url="^S/(.+)" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false" />
                    <action type="Rewrite" url="track/?irid={R:1}" logRewrittenUrl="false" />
                </rule>
                <rule name="/ Z-BlogPHP Imported Rule" enabled="true" stopProcessing="true">
                    <match url="^.*?" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
                <rule name="/ Z-BlogPHP Imported Rule index.php" enabled="true" stopProcessing="true">
                    <match url="^index.php/.*?" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>  
 
 
   </rules>
   
  </rewrite>
  
 </system.webServer>
 
</configuration>

修改后的规则

#rewrite ^/(?i)S/(.+)$ /track/?irid=$1 last; 不区分大小写
rewrite ^(.*)/S/(.+)$ $1/track/?irid=$2 last; 
if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
    rewrite (.*) /index.php;
}

apache规则

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^S/(.+)$ track/?irid=$1
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

不区分大小写的规则

RewriteRule ^S/(.+)$ track/?irid=$1 [NC]

https://blog.fxb.cc/54.html
最后更新 2023-01-30
评论 ( 0 )
问:叁 + 壹 = ?
OωO
隐私评论