win服务器下 子目录 子站 伪静态方法分享

迅睿框架 更新 2023-02-10 11:49:52 Swlts


win服务器下 子目录 子站伪静态办法分享。 原理很简单,分享给大家。就是用location 标签 区分 主站和子目录的重写规则 web.config 

虽然目前Linux用户很多,win服务器也有很多用户使用。


根目录下的 web.config 

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


<location path="." allowOverride="false" inheritInChildApplications="false">

    <system.webServer>
        <rewrite>
            <rules>
                <rule name="已导入的规则 1" stopProcessing="true">
                    <match url=".(js|ico|gif|jpe?g|bmp|png|css)$" negate="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
 
 
</location>
 
</configuration>


子目录下的 web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="已导入的规则2" stopProcessing="true">
                    <match url=".(js|ico|gif|jpe?g|bmp|png|css)$" negate="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/en/index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


其中/en/ 改成你当前子目录名称。 


以上,用得着的朋友,帮回帖支持下。

方案

  • 眼镜 #1 · 2022-08-04 15:25:01
    收藏了,刚好要用
  • perweb #2 · 2023-02-10 11:49:52
    这个绑定目录的可以,绑定二级域名,没有生效

迅睿系统漏洞

站群分站系统
站群分站系统(2026-10-15)
子站域名新增llms.txt访问
GEO系统
GEO系统(2026-10-14)
修复下载zip空白地址问题 修复流量复刻和任务队列错误
GeoSeo收录宝
GeoSeo收录宝(2026-10-14)
新增 站长工具箱 前端首页自动调用meta 数据
滑块验证码 Gocaptcha
滑块验证码 Gocaptcha(2026-10-13)
基于开源项目 go-captcha 的行为验证码插件,滑动拼图、区域...
GeoSeo工具箱
GeoSeo工具箱(2026-10-13)
优化巡检任务
GeoSeo排名助手
GeoSeo排名助手(2026-10-11)
加入大模型自定义
SEO聚合关键字
SEO聚合关键字(2026-10-11)
优化关键字列表页最多支持1万篇文章,过多会导致服务器扛不住;
CMS内容同步复制
CMS内容同步复制(2026-10-10)
增加时间是否更新的开关