我正在尝试制定将 URL 参数附加到 URL 的 IIS URL 重写规则。url 参数是hssc. 因此,通过服务器处理的任何 url 都需要该参数。请记住,某些 url 已经有自己的参数,而其他 url 则没有,还有根 url 等,有时需要添加?hssc=1或&hssc=- 所以,如果我有这样的 URL:
我还希望 URL 不应该被隐藏(就像在后台重写一样)。我需要 URL 出现在 URL 中,因此当用户复制 URL 或将其添加为书签时,参数就在那里。
我已经设置了条件来匹配它\&hssc|\?hssc- 现在我只需要一种编写 URL 的方法,这样它就会出现并保留已经存在的原始 URL 部分。
我想重写以下网址 -
http://localhost:99/Product/CategoryLevel?CategoryId=65&ProductName=Vitamins
同
http://localhost:99/Product/Vitamins,
(要么)
http://localhost:99/Product/CategoryLevel/Vitamins
(要么)
http://localhost:99/Vitamins
(或)如何从URL中删除(或)隐藏查询字符串(显示给用户)?
我尝试使用url重写模块(iis)和asp.net路由并在互联网上搜索解决方案,但我没有找到正确的解决方案,请建议任何解决方案.
asp.net-mvc url-rewriting query-string asp.net-mvc-4 url-rewrite-module
我正在尝试使用此Dockerfile安装URL Rewrite 2.0:
FROM microsoft/aspnet:4.6.2
WORKDIR /inetpub/wwwroot
COPY obj/Docker/publish .
ADD https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi /install/rewrite_amd64.msi
RUN net start MSIServer
RUN msiexec.exe /i c:\install\rewrite_amd64.msi /quiet /passive /qn /L*v "C:\package.log"
Run Code Online (Sandbox Code Playgroud)
构建容器映像时,看到以下错误消息:
无法访问Windows Installer服务。如果未正确安装Windows Installer,则会发生这种情况。请与您的支持人员联系以获得帮助。
运行容器后查看package.log,我看到了:
SI (c) (30:A4) [08:32:10:438]: Failed to connect to server. Error: 0x80040150
SI (c) (30:A4) [08:32:10:438]: Note: 1: 2774 2: 0x80040150: 2774 2: 0x80040150
Run Code Online (Sandbox Code Playgroud)
执行中 net start msiserver在正在运行的容器上将返回一条消息,表明该服务已启动,Google表示读取注册表可能是0x80040150的问题。
是否期望以这种方式安装URL Rewrite可以正常工作,还是我需要以某种方式提升权限?
更新:msiexec在正在运行的容器上运行相同的命令将成功安装URL Rewrite。
我正在尝试在我的 IIS 上设置 URL 重写,以便它处理 http 并让我们加密。我的目标是以下
1) 所有到http://example.com、http://www.example.com和https://www.example.com 的流量都应该重定向 (301) 到https://example.com
2) 应保留任何子页面和查询字符串,以便http://www.example.com/whatever/login.aspx?username=blabla变为https://example.com/whatever/login.aspx?username=blabla
3) 对http://example.com/.well-known/acme-challenge/ * 和http://www.example.com/.well-known/acme-challenge/ * 的所有请求(其中“*”可以是任何子页面和查询字符串)不应该被重定向
就像我已经尝试过一切,但我无法让它发挥作用。
我遇到了各种<rewrite>规则,并注意到有很多变量似乎是相同的。在IIS服务器变量的文件是不是真的帮助,例如它没有解释什么区别PATH_INFO和URL,它甚至没有提及REQUEST_URI在所有等
{HTTP_URL} = /path/to/file.ext?key=value
{PATH_INFO} = /path/to/file.ext
{R:1} = /path/to/file.ext
{REQUEST_URI} = /path/to/file.ext?key=value
{UNENCODED_URL} = /path/to/file.ext?key=value
{URL} = /path/to/file.ext
{URL_PATH_INFO} = /path/to/file.ext
Run Code Online (Sandbox Code Playgroud)
除了查询字符串,到目前为止我还没有发现任何其他差异。是否有其他差异,为什么我们有多个具有相同值的变量?
我在网站上设置了URL重写,用户可以在子网站上创建自己的网站.
<rule name="CName to URL - Rewrite" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.basedomain\.com" />
</conditions>
<action type="Rewrite" url="render_page.aspx?site={C:1}&page={R:0}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
例如,用户可以创建一个页面http://client.basedomain.com/about-us,这将成功地将"client"和"about-us"传递给我的应用程序.
我需要做的是在其域后面的特定页面名称的情况下覆盖此行为.
因此,如果访问了http://client.basedomain.com/restricted页面,它将不会执行上述重写,而是将其重写为url"render_page_restricted.aspx?site = {C:1}
任何帮助是极大的赞赏.
我在我的Web服务器上安装了Url Rewrite Module,该服务器运行Windows Server 2012 R2,网址如下:http://staging.mysite.net/
我将图像,字体,脚本等加载到Azure CDN中.
我在Web.config中指定了以下规则:
<rewrite>
<rules>
<rule name="CDN: fonts" stopProcessing="true">
<match url="^fonts/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/fonts/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: images" stopProcessing="true">
<match url="^images/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/images/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: pdf" stopProcessing="true">
<match url="^pdf/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/pdf/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: scripts" stopProcessing="true">
<match url="^scripts/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/scripts/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: style" stopProcessing="true">
<match url="^style/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/style/{R:1}" appendQueryString="true" />
</rule>
</rules> …Run Code Online (Sandbox Code Playgroud) 我安装了一个内容管理系统插件,在http://www.domain.com/index.php?eID=dd_googlesitemap下为Google提供了一个站点地图,如何在我的.htaccess中添加重写规则,以便在http://www.domain.com/sitemap.xml而不是?
我已将下面的重写规则添加到我的web.config中.它完美地工作,阻止所有提到的推荐垃圾网站.但是,今天突然我注意到social-buttons.com我的Google Analytics 中出现了这个问题.这可能与我在下面定义的规则有关吗?
<rule name="abort referer spam requests" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_REFERER}" pattern="(semalt\.com)|(buttons\-for\-website\.com)|(simple\-share\-buttons\.com)|(darodar\.com)|(social\-buttons\.com)" />
</conditions>
<action type="AbortRequest" />
</rule>
Run Code Online (Sandbox Code Playgroud) 嗨,我在IIS中使用URL重写模块.我会创建一个规则来转换小写网址.但是,我遇到了问题.我的目标是做到以下几点:
http://www.doMain.com/App/ActIon?X=1&y=3&JJ=3... => http://www.domain.com/app/action?X=1&y=3&JJ=3...
Run Code Online (Sandbox Code Playgroud)
我的第一次失败尝试是:
<rule name="LowerCaseRule1" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
结果:
http://www.doMain.com/App/ActIon?X=1&y=3&JJ=3... => http://www.domain.com/App/ActIon?X=1&y=3&JJ=3...
Run Code Online (Sandbox Code Playgroud)
它只适用于域(因为URL变量只有域)
我的第二次失败尝试是:
<rule name="Convert to lower case" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
Run Code Online (Sandbox Code Playgroud)
结果:
http://www.doMain.com/App/ActIon?X=1&y=3&JJ=3... => http://www.domain.com/app/action?x=1&y=3&jj=3...
Run Code Online (Sandbox Code Playgroud)
这也适用于查询字符串.因此我没有为我服务.
我的第三次失败尝试是:
<rule name="Convert to lower case" stopProcessing="true">
<match url="^(.*[A-Z].*)(\/.*)" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{R:1}}{R:2}" redirectType="Permanent" />
</rule>
Run Code Online (Sandbox Code Playgroud)
结果:
http://www.doMain.com/App/ActIon?X=1&y=3&JJ=3... => http://www.domain.com/app/ActIon?X=1&y=3&JJ=3...
Run Code Online (Sandbox Code Playgroud)
这个问题不适用于最后一条路径.
这导致我不需要满足以下规则:
http://www.doMain.com/App => http://www.domain.com/app
Run Code Online (Sandbox Code Playgroud)
问题:
是否有任何规则允许我做我需要的事情?
这个模块是否正确?
因为我有另一种选择是使用ASP.NET路由引擎(例如https://github.com/schourode/canonicalize)
iis ×4
iis-7 ×3
asp.net-mvc ×2
iis-7.5 ×2
regex ×2
.htaccess ×1
azure ×1
azure-cdn ×1
dockerfile ×1
iis-6 ×1
lets-encrypt ×1
mod-rewrite ×1
query-string ×1
web-config ×1