我知道在htaccess但是如何使用web.config规则属性重写站点地图的URL.我尝试过以下方法,但都没有效果
<rule name="sitemap URL" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^/sitemap.xml$" /> - Not working
<add input="{HTTP_HOST}" pattern="^domain.com/sitemap.xml$" /> - Not working
<add input="{HTTP_HOST}" pattern="^www.domain.com/sitemap.xml$" /> - Not working
</conditions>
<action type="Rewrite" url="foldername/sitemaps/sitemap-a.xml" />
</rule>
Run Code Online (Sandbox Code Playgroud)
也试过了
<rule name="sitemap URL" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^.+\.(local|www)?(domain).+\.(?:xml)$" />
<action type="Rewrite" url="foldername/sitemaps/sitemap-a.xml" />
</rule>
Run Code Online (Sandbox Code Playgroud) asp.net web-config url-rewriting sitemappath url-rewrite-module
我已经根据互联网上的说明在 IIS 7.5 上为 Atlassian Confluence 设置了一个反向代理。
我想将所有流量重定向到“docs.unimaze.com”到同一服务器上的“localhost:8090”。
我是这样做的:
(.*)使用正则表达式匹配模式(忽略大小写)http://localhost:8090/{R:1}(附加到查询字符串并停止处理后续规则。为了使一切正常,我必须做的另一件事(来自https://serverfault.com/questions/76013/iis6-vs-iis7-and-iis7-5-handling-urls-with-plus-sign-in -base-not-querystr ) 是在服务器上运行此命令,以便允许 URL 中带有“加号”的 URL。
%windir%\system32\inetsrv\appcmd set config "WebSiteName"
-section:system.webServer/security/requestFiltering -allowDoubleEscaping:true
Confluence 本身似乎工作得很好,但是当尝试从外部应用程序编辑模块时(LucidChart 图表失败),因为重定向到外部应用程序也会被重写,例如尝试重定向到这个 URL:
http://docs.unimaze.com/documents/edit/4b157fd9-8e28-4d70-8587-0fdd0839fbca?callback=...
当重定向实际上应该指向外部应用程序时,因此它应该不受重写规则的影响:
https://www.lucidchart.com/documents/edit/4b157fd9-8e28-4d70-8587-0fdd0839fbca?callback=...
有没有简单的方法来解决这个问题?
在我的开发机器上,我试图将 IIS 配置为反向代理,以将来自端口 443 的请求转发到本地运行的 nodejs 应用程序。
请求转发得很好,但有时 nodejs 应用程序会尝试将浏览器重定向到外部站点,而 IIS url 重写模块也会更改为指向本地服务器。
我正在使用https://localhost/test访问站点
IIS 将请求重新路由到节点应用程序http://localhost:14819/test
节点应用程序返回一个 http 302,位置标头设置为https://example.com/ someroute
IIS 将其转换为https://localhost/someroute
我希望外部 url 不被 IIS 触及。这该怎么做?这是我的 Web.config 内容
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="ReverseProxyInboundRule1" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^test(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^localhost" />
</conditions>
<action type="Rewrite" url="http://localhost:14819/test{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我对托管在 Windows 服务器上的项目使用标准的 web.config 文件。它负责 2 个任务。
见下文:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1" stopProcessing="true">
<match url="index\.asp(?:l)?" />
<conditions>
<add input="{HTTP_HOST}" pattern="example\.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/" />
</rule>
<rule name="CanonicalHostNameRule2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这很好用,除了 1 个问题。索引重定向将所有子目录重定向到主目录。
例如:
http://www.example.com/index.asp像它应该的那样 重定向到http://www.example.com。
但是,http://www.example.com/about/index.asp 也重定向到http://www.example.com。我希望它重定向到http://www.example.com/about/
任何帮助将不胜感激。
在我的网站上,我遇到这样的情况:我的 URL 有时会获得由我们网站之外的系统附加的查询字符串参数。
因此,它不是像这样:http://www.domain.com?myquery=blahor http://www.domain.com,而是 url http: http://www.domain.com?myquery=blah&theirpara=blahor http://www.domain.com?theirpara=blah。
当用户使用“irpara”参数访问时,我想将 301 重定向到没有它的 URL。
我尝试过使用 URL 重写模块,但没有真正取得任何进展。如果可能的话,最好在 IIS/web.config 级别而不是 Response.RedirectPermanent 级别执行此操作。
我认为使用规则(URL 写入模块)进行设置会很好,但说实话,我不知道如何解决这个问题。我正在使用以下规则删除尾部斜杠,但不确定如何修改它以满足此需要。
<!--To always remove trailing slash from the URL-->
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
关于如何设置它有什么想法吗?
在 IIS7.5 中,我有一个将 http 请求重定向到 https 的 URL 重写规则。如果我选中“需要 SSL”,则会得到 403 Unauthorized 而不是重定向,这是有道理的。
有没有办法将它们一起使用?甚至会有好处吗?我假设没有,因为每个 http 请求都会被重定向,但我在这里检查以防万一我错了。
这安全吗?
我试图找出一个URL重写规则,以仅在访问特定路径(如下所示)时将http请求重写为https。我已经尝试了很多事情,在测试模式中似乎它们应该可以工作,但是从不行。
访问的网址:http : //example.com/books/test.css
我需要检查http://和/ books /以便在下面形成正确的网址。
所需网址:https://example.com/books/test.css
应该忽略http://example.com/book/test.css的请求。
这是重写规则:
<rewrite>
<rules>
<rule name="redirect all requests" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}"
matchType="IsFile"
negate="true"
pattern=""
ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)
以下两个文件都存在。一个 GET 成功,另一个抛出 500。
200
GET http://greenearth.game/node_modules/aurelia-leaflet/dist/amd/leaflet.js
Run Code Online (Sandbox Code Playgroud)
500(URL 重写模块错误。)
GET http://greenearth.game/node_modules/aurelia-open-id-connect/dist/amd/open-id-connect-role-filter.js
Run Code Online (Sandbox Code Playgroud)
500错误具体是:
“无法添加类型为 'rule' 且唯一键属性 'name' 设置为 'redirect all requests' 的重复集合条目”。
两个问题:
放在元素<remove name="redirect all requests" />的顶部<rules>回答 #2 但不是 #1。
我试图阻止除内部管理员IP地址以外的所有IP地址的特定url页(http://www.testdomain.com/login)。我没有阻止模式登录的问题,但是我想在本地进行测试,以确保将内部管理IP排除在/ login url的阻止规则之外。看看我到目前为止有什么...
<rewrite>
<rules>
<rule name="RequestBlockingRule1" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*login*" negate="false" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{HTTP_X_Forwarded_For}" pattern="92.102.130.65" />
</conditions>
<action type="None" />
</rule>
<rule name="RequestBlockingRule2" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{URL}" pattern="*login*" />
</conditions>
<action type="CustomResponse" statusCode="404" statusReason="File or directory not found." statusDescription="The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." />
</rule>
Run Code Online (Sandbox Code Playgroud)
我还想要重复相同的规则,但要查询http://www.testdomain.com/home.aspx的查询字符串?ctl = login
<rule name="RequestBlockingRule3" enabled="true" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Powershell DSC安装URL重写器并且它一直在失败.当我删除安装重写器的步骤时,脚本会成功.
我的设置是使用Visual Studio Team Services(VSTS)构建和发布管道我执行ARM模板来创建一个缩放集,指向powershell dsc脚本.
"extensionProfile": {
"extensions": [
{
"name": "Microsoft.Powershell.DSC",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.72",
"autoUpgradeMinorVersion": true,
"forceUpdateTag": "[parameters('dscVmssUpdateTagVersion')]",
"settings": {
"configuration": {
"url": "https://myblobname.blob.core.windows.net/dsc/scalesetSetup.zip",
"script": "prepareServer.ps1",
"function": "PrepareServer"
},
"configurationArguments": {
"nodeName": "localhost",
"envName": "[parameters('envName')]"
}
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
在这个脚本中,我正在启用Windows功能,安装Web部署和URL重写器.当没有安装重写器时一切正常,但是当我以下列任何一种方式添加它时失败.
DSC脚本实际上看起来像:
Configuration PrepareServer
{
Param ( [string] $nodeName, [string] $envName )
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node $nodeName
{
# Web Server
WindowsFeature WebServerRole
{
Name = "Web-Server"
Ensure = "Present"
} …Run Code Online (Sandbox Code Playgroud) iis ×7
asp.net ×3
web-config ×3
azure ×2
iis-7.5 ×2
c# ×1
confluence ×1
dsc ×1
powershell ×1
sitemappath ×1
ssl ×1