【问题标题】:Prevent subdirectory from being a part of the link?防止子目录成为链接的一部分?
【发布时间】:2019-05-23 07:17:05
【问题描述】:

我目前正在重构我的网站,我注意到我的嵌套结构显示出来,就像我正在浏览 File Explorer。我在网上找不到任何关于阻止它以这种方式出现的信息。

我希望确保我的项目井井有条且井井有条,这会导致页面有时达到 5 层深(基本示例):

mywebsitedotcom/gaming/2d/arcade/pong.aspx

我希望它看起来像:

mywebsitedotcom/gaming/pong.aspx

如何确保网址不显示我的组织结构的一部分?

【问题讨论】:

    标签: c# asp.net webforms webaddress


    【解决方案1】:

    您可以使用称为 UrlMapping 的东西。

    它是你的 web.config 中的一个元素,它类似于:

    <system.web>
    
    <urlMappings enabled="true">
    
        <add url="~/gaming/2d/arcade/pong.aspx"
            mappedUrl="~/gaming/pong.aspx"/>
    
        <add url="~/anotherurl/another.aspx"
            mappedUrl="~/otherurl/otherpage.aspx"/>
    
    </urlMappings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      • 1970-01-01
      • 2015-05-28
      相关资源
      最近更新 更多