Windows IIS Forwarding domain.de to www.domain.de - windows

before i start, i tried the search bar and i saw posts but these didnt really help me.
So im currently trying to foward my domain to force HTTPS and www.
so like when i type mydomain.de it forwards me to https://www.mydomain.de
this is my web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="http to https secure" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^(www.)?speargaming.de" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I dont see what i did wrong there.

Related

How to Rewrite URL in Tomcat 9

Just wanted to know how to rewrite the URL in Tomcat. previously we use to use IIS to rewrite the URL and not we have moved to Tomcat 9.
In ISS We have created web.config file and created a rewrite map.
In Web.config file script was written as
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name="Redirect rule1 for Login_Redirect" />
<rule name="Rewrite rule1 for AdobeRewriteMap">
<match url=".*" />
<conditions>
<add input="{AdobeRewriteMap:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
<rewriteMaps>
<remove name="Login_Redirect" />
<remove name="AdobeRewriteMap" />
<rewriteMap name="AdobeRewriteMap">
<add key="/updateforms" value="<adobe URL>" />
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>
Now we would like the implement the same in tomcat. Can anyone help me out to achieve the same functionality in Tomcat 9.
Thanks,
VJ.
we would like the implement the same in tomcat. Can anyone help me out to achieve the same functionality in Tomcat 9.

How to use web.config to overwrite redirect rule for a file with same name but different extension?

I have an existing web.config file to redirect a page titled privacy.asp to privacy (without the .asp extension). It works as it should.
I now have a client who had a file privacy.html and I want to send a httpResponseStatus of permanent, that being /privacy.
Here is what I tried but when pulling up the privacy.html it resolves with the .html extension but the actual page is that of the .asp.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="privacy.html">
<system.webServer>
<httpRedirect enabled="true" destination="/privacy/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<system.webServer>
<rewrite>
<rules>
<rule name="privacy" stopProcessing="true">
<match url="^privacy" />
<action type="Rewrite" url="privacy.asp" />
</rule>
</rules>
</system.webServer>
</configuration>
You could use below rewrite rule:
<rule name="privacy" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="privacy.html$" />
</conditions>
<action type="Redirect" url="privacy" appendQueryString="false" />
</rule>
<rule name="rewrite rule" stopProcessing="true">
<match url="privacy$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="privacy.asp" appendQueryString="false" logRewrittenUrl="true" />
</rule>
Note: do not forget to remove the location path and old URL rewrite rule.
Rregards,
Jalpa

Redirect HTTP to HTTPS won't work (with URL Rewrite)

I tried to make http automaticlly redirect to https.
I exactly followed those steps: https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https
This is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="SSL Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The error I get when visiting the site is ERR_TOO_MANY_REDIRECTS
I found a solution that works if you are using Cloudflare
On cloudflare you can just select 'Automatic HTTPS Rewrites' and this will work.

IIS rewrite how to intercept a set cookie value

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite requests" enabled="true">
<match url="(.*)" />
<action type="Rewrite" url="https://site1.domain1.net/{R:0}" />
</rule>
</rules>
<outboundRules>
<rule name="Rewrite outbound" enabled="true">
<match filterByTags="None" pattern="(.*)site1\.domain1\.net(.*)" />
<action type="Rewrite" value="{R:1}site2.domain2.com{R:2}" />
</rule>
<rule name="Rewrite cookie">
<match serverVariable="{HTTP_COOKIE}" pattern="(.*)site1\.domain1\.net(.*)" />
<action type="Rewrite" value="{R:1}site2.domain2.com{R:2}" />
</rule>
<preConditions>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Ok so I have a frontend server which is accessed by site2.domain2.com and all traffic to it should be url rewrote as site1.domain1.net this works pretty easily. My problem is the site running on site1.domain1.net writes a cookie with a bunch of non-standard values for the application it runs. I need to be able to change a value written to the cookie for logon purposes.
The line I need to target is below
https%3a%2f%2fsite1.domain1.net%2flgn%2fauth2%2fagent%2fsrms%2frefresh
It doesn't have any standard tag like url=value or host=value it's just the line above, I need to catch the site1.domain1.net part and change to site2.domain2.com but not having much luck.
You can see in the code at the top where I tried to do this, unsuccessfully as I don't know much about playing with the cookies. Suggestions?
I was close but wasn't using the right stuff, though a bunch more trial and error I managed to figure it out.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite requests" enabled="true">
<match url="(.*)" />
<action type="Rewrite" url="https://site1.domain1.net/{R:0}" />
</rule>
</rules>
<outboundRules>
<rule name="Rewrite outbound" enabled="true">
<match filterByTags="None" pattern="(.*)site1\.domain1\.net(.*)" />
<action type="Rewrite" value="{R:1}site2.domain2.com{R:2}" />
</rule>
<rule name="Modify Cookie">
<match serverVariable="RESPONSE_Set_Cookie" pattern=".*" />
<conditions>
<add input="{R:0}" pattern="(.*)site1\.domain1\.net(.*)" />
</conditions>
<action type="Rewrite" value="{C:1}site2.domain2.com{C:2}" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>

How to remove index.php in codeigniter on Windows Server and IIS?

How to remove index.php in codeigniter on Windows Server and IIS?
I found this when i search for answer
How to rewrite the index.php of Codeigniter on Windows Azure
but when i try my CI still need index.php to run
whre the web.config file must be add and is there any other step before i edit my web.config?
If URL Rewrite module is not installed, please install it from here http://www.iis.net/downloads/microsoft/url-rewrite
Please check the complete web.config file. Place this in the same folder where the index.php is placed.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Its working in IIS in Windows server 2008 R2
This answer is a little more secure (paranoid) than the others, and is based on the way CakePHP does it. This assumes that you have a directory named "public" which contains all of the js, css, image, and font files. If you have other extensions you want to allow, add them to the second rule. You can change the directory name from "public" to anything be replacing the word "public" in rule 1 and 2.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Exclude direct access to public/*" stopProcessing="true">
<match url="^public/(.*)$" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="Rewrite routed access to assets by extension" stopProcessing="true">
<match url="^(.*)(\.(css|js|otf|eot|svg|ttf|woff|woff2|jpg|png|gif|ico))$" />
<action type="Rewrite" url="public/{R:1}{R:2}" appendQueryString="false" />
</rule>
<rule name="Rewrite requested file/folder to index.php" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Make web.config put in the root directory.
User code:
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<rule name="RuleRemoveIndex" 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" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
You should upload the web.config file with your project and write the code
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Hide Yii Index" 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" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
If You are still getting the problem then go through the following link
PHP MVC Framework IIS index.php solution

Resources