繁体   English   中英

IIS URL重写移动文件夹

[英]IIS URL Rewrite mobile folder

嗨,我有一个网站,以前曾经有一个单独的移动端,它的链接由google索引。 我现在将其更改为响应式设计。 我在共享服务器上,因此我必须通过URL Rewrite进行此重定向,有什么方法可以重定向/ mobile /子文件夹之后的所有内容以及以前一直存在于其根文件夹中的所有内容。规则。 这样就会发生以下情况:

Domain.com/mobile -> domain.com
Domain.com/mobile/folder1/page1/variable -> domain.com/folder1/page1/variable
Domain.com/mobile/folder1/page2/variable -> domain.com/folder1/page2/variable
Domain.com/mobile/folder2/page1/variable -> domain.com/folder2/page1/variable
Domain.com/mobile/folder2/page2/variable -> domain.com/folder2/page2/variable

这看起来像您的web.config中的以下内容(基本匹配所有以mobile /开头的“根”请求,然后重定向到等效的请求(使用301,这是用于SEO的正确选择):

<configuration>
    <system.webServer>    
        <rewrite>
            <rules>
                <rule name="Redirect mobile" stopProcessing="true">
                    <match url="^mobile/(.*)$" />
                    <action type="Redirect" url="{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM