using svgz in html server - svg

I use chrome to visualize a svg file which I put on a server, that works fine. Here's the dead simple html for it:
svg
However, when I try to use svgz instead, it doesn't work. Here's the code I use:
svgz
Here the error:
This page contains the following errors:
error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error.
Looks to me that the browser doesn't decompress the file first.
Any idea how can I make this (much smaller) svgz file to display nicely on my browser?

I had to add a .htaccess in the web folder root with the following content:
AddType image/svg+xml svg
AddType image/svg+xml svgz
AddEncoding x-gzip .svgz
From those 2 links here and here

The info on this page solve my problem with IIS
http://forums.iis.net/t/1175276.aspx/1
<system.webServer>
<rewrite>
<outboundRules>
<rule name="Rewrite SVGZ header" preCondition="IsSVGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<preConditions>
<preCondition name="IsSVGZ">
<add input="{PATH_INFO}" pattern="\.svgz$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>

It looks like it's fixed in build 13536 and greater ⟨http://code.google.com/p/chromium/issues/detail?id=9737⟩ so I guess you just have to upgrade the browser?

Related

cannot display svgz files correctly in browser

I try to display a svgz file like this...
<object id="svgimage" data-imagepath="Images/file.svgz"></object>
But the only thing displayed is a bunch of weird characters shown in the image below..
In my IIS I do have mimetype for svgz and svg so that is correct, but why isn't the svgz file displayed correct?
UPDATE:
It does help to include this rule in web.config. But this only works if I have the svgz file in a subfolder of the webb application. If I try to use a svgz file that is another site (but on the same server) it does not work.
<rewrite>
<outboundRules>
<rule name="Rewrite SVGZ header" preCondition="IsSVGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<preConditions>
<preCondition name="IsSVGZ">
<add input="{PATH_INFO}" pattern="\.svgz$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
I use IIS Version 21H (OS build 22000.708)

IIS Reverse Proxy for specific URL path - URL Rewrite Module Error

I have one windows service which is running some application with REST endpoint on localhost:5001/api/...
So I installed IIS 10 with rewrite module to create reverse proxy for HTTPS to that service. That worked great.
Now I want to use the same IIS site for hosting a website, which should consume that service on same url.
So I tried to change the pattern of my iis rewrite url to 'api/(.*)' so it should just proxy the /api requests. Testing the pattern is exactly what I want to: Browsing server.domain/api/function matches and the rewrite is done and server.domain is not rewritten.
But now browsing server.domain will often return 'HTTP Error 500.52 - URL Rewrite Module Error'.
Sometimes loading the page works great. But after reload I will get that error again.
My web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="true">
<match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:5001/(.*)" />
<action type="Rewrite" value="https://server.domain/{R:2}" />
</rule>
<rule name="ReverseProxyOutboundRule2" preCondition="ResponseIsHtml1" enabled="true">
<match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:5001/(.*)" />
<action type="Rewrite" value="https://server.domain/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rules>
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
<match url="api/(.*)" />
<action type="Rewrite" url="http://localhost:5001/{R:0}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
<httpErrors errorMode="Detailed" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS, DELETE, PUT" />
<add name="Access-Control-Max-Age" value="1000" />
<add name="Access-Control-Allow-Headers" value="x-requested-with, Content-Type, origin, authorization, accept, client-security-token" />
</customHeaders>
</httpProtocol>
<urlCompression doDynamicCompression="false" />
</system.webServer>
</configuration>
I have no idea why there are two outboundRules. IIS created them automatically when I decided to create reverse proxy rules.
If I disable static content compression, all will work without problems.
Dynamic compression module is not installed.
So I have multiple questions:
- why do I get the "Rewrite URL" error for pages which should not be rewritten and the rewritten ones will work without any problem
- why static compression creates rewrite url errors
- how should I configure my IIS to do compression and work with rewriting (I checked the module order and the static compression module is above the rewrite module).
Best,
Robin
Did you create reverse proxy rule by using URL rewrite rule template? If so, you might enable outbound rules. These outbound rules are mainly used when a client can't access source file behind DMZ server. If you client are able to access the domain on backend server, then you don't need these outbound rule.
The reason for IIS return 500.52 error is IIS can't apply outbound rule for a encoded response body from backend server.
So you have to either disable httpcompression or rewrite the incoming accept-encoding header.
I'm afraid it is unavailable to make httpcompression and outbound rule work side by side because rewrite module can't rewrite a compressed entity.
https://learn.microsoft.com/zh-cn/archive/blogs/friis/iis-with-url-rewrite-as-a-reverse-proxy-part-2-dealing-with-500-52-status-codes

How writing a url rewrite inbound rule for clean URLs for IIS

I have running Typo3 on server 2012R2 and IIS. On the same server also exchange is installed.
Typo3 now creates clean URLs, but this URLs always creates a 404 error. I found a solution to solve this problem with
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="SpeakingURL" enabled="false">
<match url="(^(typo3|fileadmin|typo3temp|uploads)/|\.(php|js|css|jpg|png|gif|pdf)$)" negate="true" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
but than exchange is not working correctly anymore. So I have to look for a solution which detects only clean URLs.
Example: http;//www.myDomain.com/customers/name/location
This URL I have to send to index.php.
There is no querystring in the url and no dot or any extension in the path.
How can I build a rule for the IIS URL rewrite, that incomming clean URLs will be passed to index.php?
Your problem are two kinds of virtual URLs.
I don't know much about exchange, but I know TYPO3.
In TYPO3 you have some few real folders for files like images, CSS, JS and all HTML is virtual. While you have exact pathes for the files only your virtual content is responsible for pathes to the HTML (virtual pages). That makes it difficult to give fix rules for rewrites.
In normal TYPO3 installations you have only those real files and the rest is virtual and handled by /index.php.
But that only is valid if you use TYPO3 9 or the extension realurl (or the old simulatestatic). otherwise TYPO3 only uses index.php and handles the rest in URL parameter (e.g. ?id=124&L=2&type=98)
Solution:
disable realurl (con: no nice URLs)
or use the extension staticfilecache, which exports all CMS-pages as real files so no rewrite is necessary (con: no 'dynamic' content).
It seems to be, that I found a solution for my problem. Up to now, it works fine for me.
I have added the code below in the system.webServer section in the web.config file under wwwroot.
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<clear />
<rule name="Clean URL" enabled="true">
<match url="(.*)" />
<action type="Rewrite" url="index.php" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
</rule>
</rules>
</rewrite>
This is for Typo3 9,5+

static url rewrite, using rewrite map is not working

I have a website on azure, and I am trying to make some user-friendly urls to my websites use.
I have downloaded IIS remote manager, and did as it was explained here.
Although the article is since 2008, the GUI of the remote IIS manager is still almost the same.
after defining the rewrite map, and the rule that looks inside the map, this is the web.config that was generated:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rewriteMaps>
<rewriteMap name="StaticRewrites">
<add key="/niceurlpart" value="/Menu/master/#/Menu?Token=7926983e-c64e-4547-85f5-d85e3c06c7a8" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Rewrite rule1 for StaticRewrites" patternSyntax="ExactMatch">
<match url=".*" />
<conditions>
<add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
when I enter inside the address bar: mydomain.com/niceurlpart I get:
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
Also, when I try to test the pattern inside the remote IIS manager, it fails..
am I missing something?
Not sure on the syntax of doing this in web.config, but the # part of a URL doesn't reach the server, so using that in your rule won't work.
If you are using angular type app and are using # for routing, then try using HTML5 mode which will get rid of the hash.
If your are after SEO, you can google '_escaped_fragment_' to get the hash value to your server. Also if SEO is your goal then we use _escaped_fragment_, along with this tool https://prerender.io

Outbound IIS Rewrite Rule to set Content Type Response Header

Trying to get IIS to rewrite the response content type from image/jpeg to application/octet-stream for requests to resources like this:
http://www.example.org/path/to/images/some-image.jpg#download
to respond with the content type of application/octet-stream so browsers will prompt for download. I'm trying not to have to write a handler in the application to do it and having IIS do it would be easier.
Here is what I have so far:
<outboundRules>
<rule name="Download Photos" preCondition="Photo Images">
<match serverVariable="RESPONSE_CONTENT_TYPE" pattern="image/jpeg" />
<action type="Rewrite" value="application/octet-stream" />
</rule>
<preConditions>
<preCondition name="Photo Images">
<add input="{REQUEST_LOCATION}" pattern="photos/.*\.jpg\?#download$" />
</preCondition>
</preConditions>
</outboundRules>
Your problem is that # is available in the browser only. The server can not read it. You can read more about that in Wiki: https://en.wikipedia.org/wiki/Fragment_identifier

Resources