Font files not loading in Drupal site running in Azure Server - azure

Here's a font file that resides in the server. But it seems to be throwing 404
And here's the web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- Don't show directory listings for URLs which map to a directory. -->
<directoryBrowse enabled="false" />
<!--
Caching configuration was not delegated by default. Some hosters may not
delegate the caching configuration to site owners by default and that
may cause errors when users install. Uncomment this if you want to and
are allowed to enable caching.
-->
<!--
<caching>
<profiles>
<add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00" />
</profiles>
</caching>
-->
<rewrite>
<rules>
<rule name="Protect files and directories from prying eyes" stopProcessing="true">
<match url="\.(engine|inc|install|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format|composer\.(json|lock)|\.htaccess)$" />
<action type="CustomResponse" statusCode="403" subStatusCode="0" statusReason="Forbidden" statusDescription="Access is forbidden." />
</rule>
<rule name="Force simple error message for requests for non-existent favicon.ico" stopProcessing="true">
<match url="favicon\.ico" />
<action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="File Not Found" statusDescription="The requested file favicon.ico was not found" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
</rule>
<!-- To redirect all users to access the site WITH the 'www.' prefix,
http://example.com/foo will be redirected to http://www.example.com/foo)
adapt and uncomment the following: -->
<!--
<rule name="Redirect to add www" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}" />
</rule>
-->
<!-- To redirect all users to access the site WITHOUT the 'www.' prefix,
http://www.example.com/foo will be redirected to http://example.com/foo)
adapt and uncomment the following: -->
<!--
<rule name="Redirect to remove www" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="http://example.com/{R:1}" />
</rule>
-->
<!-- Pass all requests not referring directly to files in the filesystem
to index.php. -->
<rule name="Short URLS" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
<!-- If running Windows Server 2008 R2 this can be commented out -->
<!-- httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
</httpErrors -->
<defaultDocument>
<!-- Set the default document -->
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Site is running in an Azure Server. And my guess is that it is because of some rewrite rules, which am not able to figure out. Any inputs would be highly appreciated.

Try adding MIME Maps for the static content.
ie, after the </defaultDocument>, add the following lines:
<staticContent>
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".css" mimeType="text/css" />
</staticContent>

Related

URL Rewrite Module 2.1 redirection http to https not working

They changed the url rewrite Module version (URL Rewrite Module 2.1) and now the redirection from http to https is not working.
Has anyone encountered the same problem?
Application : Angular
System : Windows Server IIS 10
This is the web.config file (it was working for the earliest version of URL rewrite : urlrewrite2.exe)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions applyToWebDAV="false">
<add fileExtension=".pdf" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
<directoryBrowse enabled="true" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Credentials" value="true" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Thanks.
For http://example.com:80 to https://example.com:443 your rule posted in the question is correct and working fine on my side.
If it is not working on your side, you could check the Failed Request Tracing logs might give you the information about the issue. The issue might be something else.
For http://example.com:81 to https://example.com:443, you could refer to the rule below.
<rule name="Redirect with port" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*):81$" />
</conditions>
<action type="Redirect" url="https://{C:1}:443/{R:0}" />
</rule>
Output:
Let me know if you have further questions.

IIS 10 - JSON files are not serving even after configured MIME and Handlers

I have deployed a web application in IIS 10 (Windows 10) build from Node.
Files structure
I am unable to access the JSON files (for eg., http://localhost:3000/manifest.json) using the direct URL.
Receiving the following error,
I have set MIME Type as follows,
I have tried the Handler Mapping too,
My web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Static Assets" stopProcessing="true">
<match url="([\S]+[.](html|htm|svg|js|css|png|gif|jpg|jpeg|json))" />
<action type="Rewrite" url="/{R:1}" />
</rule>
<rule name="ReactRouter Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<handlers>
<add name="StaticFileModuleJson" path="*.json*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
</handlers>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
I notice that your rewrite rule have rewritten .json to .js. It has nothing to do with the handler because static file hanlder is still handling the request.
Please swap the index of js and json.
<rule name="Static Assets" stopProcessing="true">
<match url="([\S]+[.](html|htm|svg|json|css|png|gif|jpg|jpeg|js))" />
<action type="Rewrite" url="/{R:1}" />
</rule>

Redirection to (https and non www) for all requested URI via web.config

I want ( https and non www) redirection for all requested URI. Any help would be highly appreciated. Thanks,
It works well for
1) 'http' to 'https' (success)
2) 'https' to 'https' (success)
3) '/index' to '/'
4) '/contact (with www)' to '/contact (with non www)' (unsuccess)
<system.web>
<customErrors mode="On" defaultRedirect="/" >
<error statusCode="404" redirect="/" />
</customErrors>
</system.web>
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/index.php" value="/" />
<add key="/a.php" value="/a" />
<add key="/Res" value="/results#experience" />
<add key="/blog/" value="/" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}.php" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="{R:1}.php" appendQueryString="true" />
</rule>
<rule name="Redirect rule1 for Redirects">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
<rule name="Remove www prefix">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://test.com.au/{R:1}" redirectType="Permanent"/>
</rule>
<rule name="Redirect index.php" stopProcessing="true">
<match url="^(\w*/)?index\.php" ignoreCase="true"></match>
<conditions>
<add input="{HTTP_HOST}" pattern="test\.com\.au$"/>
</conditions>
<action type="Redirect" url="https://test.com.au/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseExpires" httpExpires="Tue,19 Jan 2038 03:14:07 GMT" />
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
<defaultDocument>
<files>
<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
I want all requested uri to redirect to https and non www via web.config only
Refer to the code as below:
<rewrite>
<rules>
<rule name="Redirect to non-www" stopProcessing="true">
<match url="(.*)" negate="false"></match>
<action type="Redirect" url="https://example.com/{R:1}"></action>
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" negate="true"></add>
</conditions>
</rule>
</rules>
</rewrite>

IIS 10 Subdomain to folder

help me please.
I do not speak English, so I apologize if I make mistakes
in my writing (I use google translate) :(
Create my site with these features:
Bindings > *.holos.mx, holos.mx
Path > D:\Hosteos
In this directory D:\Hosteos\web.config
I have the rules:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 0" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)\.holos\.mx" ignoreCase="false" />
<!--<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />-->
</conditions>
<action type="Rewrite" url="{C:1}/{R:1}" appendQueryString="true" /><!-- .php -->
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
Create this folder: D:\Hosteos\beta
Inside this folder I have another web.config. (D:\Hosteos\beta\web.config)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Imported Rule 1">
<match url="^life(|/)$" />
<action type="Rewrite" url="test.php" appendQueryString="false" />
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
The problem is when I enter by URL subdomains (http://beta.holos.mx/life) show error 404
When I enter URL base domain (http://holos.mx/beta/life) it shows me the content of my page test.php
How can I solve it?
You need to change URL in your rewrite action.
Your rule should be like that:
<rule name="Imported Rule 0" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)\.domain\.com" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="http://holos.mx/{C:1}/{R:1}" appendQueryString="true" /><!-- .php -->
</rule>

IIS does not encode utf-8 urls?

I'm running Joomla 2.5 on an IIS7 server.
The problem is Joomla's search engine friendly urls don't work. Whatever url I enter, it goes to index.php.
After a painful day of struggling with rewrite rules and IIS settings, I came to two realizations:
Search engine friendly urls are only broken when the urls are unicode.
In my WAMP server, on which the SEF urls work perfectly:
$_SERVER['REQUEST_URI'] is "mydomain/%D9%85%D8%AD%D8%B5%D9%88%D9%84%D8%A7%D8%AA/%D9%82%D9%84%D8%A8%DB%8C-%D8%B9%D8%B1%D9%88%D9%82%DB%8C"
But in IIS
$_SERVER['REQUEST_URI'] is "mydomain/???????/????-?????"
It looks like urls are not URLEncoded.
I have enabled unicode aliases, search engine friendly urls, and rewrite in Joomla's global configuration.
I have copy/pasted the web.config.txt into my web.config.
Here is my web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings />
<connectionStrings>
****
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" />
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=****" />
</assemblies>
</compilation>
<customErrors mode="Off" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<system.webServer>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<clear />
<add value="Default.htm" />
<add value="default.html" />
<add value="Default.asp" />
<add value="default.aspx" />
<add value="default.php" />
<add value="default.pl" />
<add value="default.cgi" />
<add value="index.htm" />
<add value="index.html" />
<add value="index.asp" />
<add value="index.aspx" />
<add value="index.php" />
<add value="index.pl" />
<add value="index.cgi" />
<add value="iisstart.htm" />
<add value="_holding.html" />
</files>
</defaultDocument>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="backup" />
<add segment="oldsite" />
<add segment="logs" />
<add segment="tmp" />
<add segment="upload" />
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/" responseMode="ExecuteURL" />
</httpErrors>
<rewrite>
<rules>
<clear />
<rule name="Common Exploit Blocking" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" />
<add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" />
<add input="{QUERY_STRING}" pattern="(\<|%3C).*script.*(\>|%3E)" />
<add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" />
<add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" />
</conditions>
<action type="Redirect" url="index.php" appendQueryString="false" redirectType="SeeOther" />
</rule>
<rule name="Joomla Search Rule" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^/search.php" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="/index.php?option=com_content&view=article&id=4" />
</rule>
<rule name="Joomla Main Rewrite Rule" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="(/[^.]*|\.(php|html?|feed|pdf|raw))$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/" />
</rule>
</rules>
</rewrite>
<caching>
<profiles>
<add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
</configuration>
This is a known bug of IIS7 and there is a hotfix for it, but I am in a hosted environment without privileges to install hotfixes. Here's a link to the Microsoft support website with detailed explanation and the resolution for the issue: FIX: A PHP application that depends on the REQUEST_URI server variable may fail when a request whose URL contains UTF-8 characters is sent to IIS 7.5
But if you can't install the hotfix, here's a workaround to get Joomla's SEF urls work with unicode:
The documentation says php's $_SERVER['REQUEST_URI'] doesn't work with unicode url rewriting, but I figured out that parameters work perfectly. We can send the url as a parameter to the php code and assign it to $_SERVER['REQUEST_URI']
Change your second rewrite rule in web.config file as follows:
<rule name="Joomla! Rule 2">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{URL}" pattern="^/index.php" negate="true" />
<add input="{URL}" pattern="/component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?requesturi={URL}" />
</rule>
The only change is modifying the url attribute of the <action> tag
In your index.php (located at the root directory of your Joomla site), add this at the top (just after the <?php opening tag)
$_SERVER['REQUEST_URI'] = $_GET['requesturi'];
Done. You have unicode in your beautified urls.

Resources