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.
Related
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
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.
I have this rule in web.config in the root of website which redirects to HTTPS:
<rewrite>
<rules>
<rule name="HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
In a subfolder I have separate Config file and I want to clear redirectiong to HTTPS but this folder also redirects to HTTPS:
<rewrite>
<rules>
<clear />
</rules>
</rewrite>
You cannot do that. Rules can be stored defined in web.config only. You can have them there or provided a path to the file where the rules are stored (but it's still defined in the web.config) like this:
<system.webServer>
<rewrite>
<rules configSource="App_Config\RewriteRules.config" />
<outboundRules configSource="App_Config\OutboundRewriteRules.config" />
<rewriteMaps configSource="App_Config\RewriteMaps.config" />
</rewrite>
</system.webServer>
If you want certain URLs not to be redirected to HTTPS then you need to create a smart rule which will detect this (or have set of rules).
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
How can I configure Intelligencia.UrlRewriter in my ASP.NET web.config file to redirect all http://www.domain.com traffic to http://domain.com?
<if header="host" match="www.yoursite.com" />
<redirect url="^(.+)$" to="http://yoursite.com$1" />
</if>
Thanks, dana, but here's what I ended up adding to my web.config file...
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.mysite.com$" />
</conditions>
<action type="Redirect" url="http://mysite.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>