Windows Server 2008 R2 SP1上的IIS 7 我在web.config中添加了以下规则,将所有传入请求redirect到HTTPS <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> 当&符号(&)出现在URL或文件名中时,它将失败。 我已经看过一些提供的解决scheme,并且对通过registry允许特殊字符不感兴趣。 有没有一种方法来执行重写编码与&或%26之前的redirect规则的&符号? HTTPSredirect规则是否使用原始URL或新重写/编码的版本?
我将Tomcat安装为IIS后面的Java应用程序服务器。 使用下面的规则,我可以重写静态页面,但很可惜,websocket连接永远不会build立: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <webSocket enable="false"/> <rewrite> <rules> <rule name="Redirect HTTP to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTPS}" pattern="^OFF$" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/foo/{R:1}" redirectType="SeeOther" /> </rule> <rule name="Redirect from IIS to Tomcat" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{CACHE_URL}" pattern="^(.*)://" /> </conditions> <action type="Rewrite" url="{C:1}://tomcat.contoso.com/foo/{R:1}" […]
Opencart有这个URL结构: http://example.com/index.php?route=common/home http://example.com/index.php?route=account/register http://example.com/index.php?route=checkout/cart http://example.com/index.php?route=checkout/checkout …我想从index.php?route=直到第一个/ ,正则expression式是index.php\?route\=[^\/]*\/ ,所以所需的url将是,例如, http://example.com/checkout 。 我试过了: location @opencart { rewrite index.php\?route\=[^\/]*\/ / last; rewrite ^/(.+)$ /index.php?_route_=$1 last; } 也试过: location / { if ($query_string ~ "^route=common/home$"){ rewrite ^/index\.php$ http://www.example.com? redirect; } } …但目前为止还没有运气,我仍然可以在URL中看到route=common/home 。 这是我目前的Nginxconfiguration: location / { try_files $uri @opencart; } location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; } […]
我们有https://example1.com/login和example2.com/login从同一个Apache服务器(2.2.22)托pipe。 我想限制/login example1.com 。 example1.com/login – > 404(最好)或403 example2.com/login – >login页面 我试过了 <Location /login> Order Deny,Allow Deny from example1.com Allow from example2.com </Location> 它禁用/login example1.com和example2.com 。 我可以限制example1.com吗?
我经历了在这里find的问题/解决scheme,尝试了很多方法(包括[L]指令),但没有什么真正的诀窍。 情况概览 Debian通过nginx运行Apache 2.2代理 目标 将所有内容redirect到/index.php并确保总是有一个斜杠。 从规则中排除以下目录: js_static 媒体 排除规则中的所有.css文件。 问题 当我打电话给www.url.com/js_static时,Apache / nginx会导致301redirect循环。 (问题也出现在跟踪斜线 – 没有区别) 当前的解决scheme nginx是这样configuration的: gzip_proxied any; rewrite ^/(.*)/$ /$1; ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:AES256+EDH'; Apache是这样configuration的: RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !^.+\.(css) RewriteCond %{REQUEST_URI} !^.+js_static RewriteCond %{REQUEST_URI} !^.+media RewriteRule ^(.*)$ /index.php/$1 AllowEncodedSlashes On 我没有看到问题出在哪里。 我有一个理论是nginx / apache重写的组合会产生问题,所以我摆弄的configuration,但无济于事,不幸的是。 有人可以在这里找出问题吗?
我正在尝试将domain.comredirect到domain.se/en ,但它不起作用。 这就像另一个重写或redirect发生在domain.se/sv 之前,我有机会 。 我试过多个VirtualHostsconfiguration和.htaccess变种没有成功。 domain.com使用指向与domain.se (主域)相同的IP的Alogging。 我怀疑WordPress插件Polylang可能会重写URL或导致redirect,然后我有机会。 我的.htacces目前看起来像这样: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} .*domain.com.*$ RewriteRule ^(.*)$ http://domain.se/en [L] </IfModule> # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 和我的VirtualHostsconfiguration看起来像这样:(注意.no和.fi也错误地redirect到.se/sv ) NameVirtualHost *:80 […]
我只为一个站点启用了“ 失败的请求跟踪” ,并且我得到了一个URL_CHANGED事件作为日志中的第三项。 1. GENERAL_REQUEST_START SiteId="1", AppPoolId="DefaultAppPool", ConnId="1610613013", RawConnId="0", RequestURL="http://example.com:80/test/wp-admin/", RequestVerb="GET" 15:35:54.176 2. GENERAL_SET_REQUEST_HEADER HeaderName="AspFilterSessionId", HeaderValue="", Replace="true" 15:35:54.192 3. URL_CHANGED OldUrl="/test/wp-admin/", NewUrl="/index.php/test/wp-admin/" 15:35:54.192 4. GENERAL_REQUEST_HEADERS […] 5. GENERAL_GET_URL_METADATA […] 6. URL_REWRITE_START […] 有人可以告诉我URL_CHANGED事件来自哪里,以及如何防止它? 更新:我们的服务器上的“默认文档”设置为“index.php”。 如果path没有指定正确的文件或文件夹,服务器是否会自动附加index.php到path? 我试图删除所有“默认文档”条目,但这并没有改变行为… Update2:我仍然在寻找这个问题的答案… 😉
我已经有lighttpd和apache一起在我正在构build的应用程序上工作。 lighty正在提供静态内容。 但是,每次请求静态资产时,都会在日志中看到not found: favicon.ico消息。 我已经添加了下面的URL重写: url.rewrite-once = ( "^/favicon.ico$" => "/assets/images/favicon.png" ) 但无济于事; 仍然收到消息。 有任何想法吗?
我试图设置我的Django应用程序与modwsgi在Apache下运行。 我已经定义了以下虚拟主机: <VirtualHost *> ServerName www.domain.com ServerAlias domain.com WSGIScriptAlias / /home/domain/apache/django.wsgi <Directory /home/domain/apache> Order deny,allow Allow from all Options -Indexes +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [QSA,L,R=301] </Directory> </VirtualHost> 最后的重写规则是使www.domain.com成为规范的站点名称。 虽然有一些错误 当我浏览到http://domain.com时 ,我被redirect到http://www.domain.com/django.wsgi/ 。 浏览> http://www.domain.com工作得很好。 我在configuration中丢失了什么? 谢谢。 更新:我改变了RewriteRule RewriteRule ^django.wsgi/(.*)$ domain.com/$1 [L,R=301]. 这个改变解决了这个问题。 如果有人能详细说明为什么/django.wsgi/部分在URL中结束,我将不胜感激。 谢谢!
重写规则是什么将subdomain.domain.tld更改为domain.tld/subdomain ? 或者我应该看看一个VirtualServer指令来获取subdomain.domain.tld并从一个DocRoot中发现, domain.tld/subdomain也发现在domain.tld/subdomain ? 重写规则要在哪里生存,如果使用重写更合适? 更新 – 在这里find链接: http : //httpd.apache.org/docs/2.2/mod/mod_rewrite.html