I have 2 domain names: domain1.com and domain2.com.
I am using the redirect script in the root to redirect each domain to it's own folder. This is working correctly. The problem I am having is that when it redirects to a folder it shows the folder name in the url after the domain name: (domain1.com/subfolder1).
My question is how to remove the ""subfolder1" from the URL?
I've tried to find a solution to this and found some guides out there but none seem to work. I have hosted nopcommerce in "subfolder1"
My web.config file as follows
<rewrite>
<rules>
<rule name="rule1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain1.com$" />
<add input="{HTTP_HOST}" pattern="^www.domain1.com$" />
<add input="{PATH_INFO}" pattern="^/subfolder1/" negate="true" />
</conditions>
<action type="Redirect" url="\subfolder1\{R:1}" />
</rule>
</rules>
</rewrite>
Related
The setup is the following :
i have 2 websites : one public and one private for our internal ERP. By using the same domaine name :
lesterrassesdadrien.fr.
When using the ARR it allow me to have the following : when someone ask for "lesterrassesdadrien.fr" the router will redirect the demand to the public website which is a wordpress, if the demand ask for "lesterrassesdadrien.fr/erp" it will redirect towards our erp website which is in PHP. here is the code inside the file applicationHost.config for the server in IIS:
<rewrite>
<globalRules>
<clear />
<rule name="lesterrassesdadrien_erp" patternSyntax="Wildcard" stopProcessing="true">
<match url="erp/*" />
<conditions>
<add input="{HTTP_HOST}" pattern="lesterrassesdadrien.fr" />
</conditions>
<action type="Rewrite" url="http://lesterrassesdadrien_erp/{R:1}" />
</rule>
<rule name="lesterrassesdadrien_public" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="lesterrassesdadrien.fr" />
<add input="{SERVER_PORT}" pattern="5000" negate="true" />
<add input="{SERVER_PORT}" pattern="5001" negate="true" />
</conditions>
<action type="Rewrite" url="http://lesterrassesdadrien_public/{R:1}" />
</rule>
</globalRules>
</rewrite>
</system.webServer>
<webFarms>
<webFarm name="lesterrassesdadrien_erp" enabled="true">
<server address="127.0.0.1" enabled="true">
<applicationRequestRouting httpPort="5000" />
</server>
</webFarm>
<webFarm name="lesterrassesdadrien_public" enabled="true">
<server address="127.0.0.1" enabled="true">
<applicationRequestRouting httpPort="5001" />
</server>
</webFarm>
</webFarms>
My problem is that when we click on a link inside the ERP website for exemple :
lesterrassesdadrien.fr/admin/... it will fail and bring me back to the public wordpress website : how to keep or add the "erp/" in front of all link inside my erp website?
My explanation are a bit confusing i believe.
Thanks in advance.
I tried to add this to the rules but with no aval :
<rule name="lesterrassesdadrien_admin" patternSyntax="Wildcard" stopProcessing="true">
<match url="admin/*" />
<conditions>
<add input="{HTTP_HOST}" pattern="lesterrassesdadrien.fr" />
</conditions>
<action type="Rewrite" url="http://lesterrassesdadrien_erp/erp/{R:1}" />
</rule>
I have an Angular running inside a MVC app. It is set up as a Virtual folder inside the Web application on the IIS.
Currently I have a IIS rewrite rule so the Routing is handled by the Angular app. But this is causing some other problems so I like to find out if it can be done with the MVC routing?
So everything at ../app/[pathandquery] should be routed to the app/[pathandquery] folder
add this to webconfig
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" 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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
So i'm using iis 8 and trying to redirect all versions of my site to 1.
Say for example:
http://www.osrshub.com
www.osrshub.com
osrshub.com
http://osrshub.com
https://osrshub.com
https://www.osrshub.com
When a user hits any of these links i need it to redirect to 1 main link.
https://www.osrshub.com
Im using windows server 2012
This rule will redirect everything to https://www.osrshub.com:
<rule name="All in one rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^www\.osrshub\.com$" negate="true" />
</conditions>
<action type="Redirect" url="https://www.osrshub.com/{R:0}" />
</rule>
You need to add this rule in your web.config file
I have a rewrite rule that redirect to mobile sites. Redirection is working properly but I want to exclude one folder say ~/Content . I am stuck in rewriting the rules to exclude one folder. Below is the rule which does the redirection to mobile site
<rule name="Mobile Rewrite" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" ignoreCase="true" negate="false" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_USER_AGENT}" pattern="android|blackberry|googlebot-mobile|iphone|ipod|opera mobile|palmos|webos" />
<add input="{HTTP_X-Device-User-Agent}" pattern="midp|mobile|phone" />
<add input="{HTTP_X-OperaMini-Phone-UA}" pattern="midp|mobile|phone" />
</conditions>
<action type="Redirect" url="http://localhost/" appendQueryString="false" redirectType="Found" />
</rule>
I am converting my website from Asp.Net Webforms to Asp.Net MVC. I want to redirect all my old .aspx files to drop the .aspx. I run IIS7 with the Url Rewrite module installed.
Example:
/about.aspx -> /about
The user will go to http://www.site.com/about.aspx and I want them redirected to http://www.site.com/about.
How do I do this using Url Rewrite? I don't want to have to do to each .aspx and put a meta-redirect in.
In your web.config file in system.webServer configuration section add:
<rewrite>
<rules>
<rule name="WebFromsToMVC" stopProcessing="true">
<match url="^(.*?)\.aspx\?*?.*$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}" />
</rule>
</rules>
</rewrite>