asp.net 网站内容私有(无法在 Internet 上搜索)
asp.net site content private (Not Searchable on internet)
我在 ASP.NET 网络表单上建立了一个网络门户。我的页面上有 content/blogs,我不想在 Internet 上搜索它(我想将其设为私有,只有登录用户才能查看)。
任何人都可以指导我如何实现它吗?
您可以添加一个 robots.txt 文件,它会告诉搜索引擎忽略某些文件夹或内容。
示例:robots.txt
User-agent: *
Disallow: /PrivateContent/
Disallow: /AdminStatistics.html
此示例告诉所有搜索引擎忽略文件夹 /PrivateContent
和 AdminStatistics.html
页面中的内容。
当然,这不会阻止临时用户(或有意搜索 robots.txt 文件的黑客)。为此,您最好通过 web.config
文件限制访问。
示例:web.config
<Configuration>
<!-- This section block unauthenticated user access to the AdminStatistics.aspx page only.
It is located in the same folder as this configuration file. -->
<location path="AdminStatistics.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<!-- This section blocks unauthenticated user access to all of the files that are
stored in the PrivateContent folder. -->
<location path="PrivateContent">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>
我在 ASP.NET 网络表单上建立了一个网络门户。我的页面上有 content/blogs,我不想在 Internet 上搜索它(我想将其设为私有,只有登录用户才能查看)。
任何人都可以指导我如何实现它吗?
您可以添加一个 robots.txt 文件,它会告诉搜索引擎忽略某些文件夹或内容。 示例:robots.txt
User-agent: *
Disallow: /PrivateContent/
Disallow: /AdminStatistics.html
此示例告诉所有搜索引擎忽略文件夹 /PrivateContent
和 AdminStatistics.html
页面中的内容。
当然,这不会阻止临时用户(或有意搜索 robots.txt 文件的黑客)。为此,您最好通过 web.config
文件限制访问。
示例:web.config
<Configuration>
<!-- This section block unauthenticated user access to the AdminStatistics.aspx page only.
It is located in the same folder as this configuration file. -->
<location path="AdminStatistics.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<!-- This section blocks unauthenticated user access to all of the files that are
stored in the PrivateContent folder. -->
<location path="PrivateContent">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>