IIS 7.5 URL Rewrite rule higher priority than folder - url-rewriting

I have this rule in web.config.
<rule name="RewriteSourceCategorySuburb" stopProcessing="true">
<match url="(news)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="default.aspx?category={R:1}" />
</rule>
The problem is I have the folder name called "news" in my root and it doesn't even have default.aspx in that folder but the web server is trying to view the folder "news" and shows this error "403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied." when I request mysite.com/news. Is it possible to make my rule to be processed higher than that folder name? Thanks.
Note: It is not just news folder it is happening all name with the same folders, I need to change a lot to rename those folders to something else. Please help. :(

I ran into a similar issue last month, and it ended up being an authentication setting within IIS. One thing you could check is the authentication settings in IIS, and change Anonymous Authentication to use the Application Pool Identity instead of the default, "IUSR".
You also need to have the URL rewrite module installed where your IIS is installed, here is a link http://www.iis.net/downloads/microsoft/url-rewrite

Related

How to set multiple redirection rules on IIS 10

I'm having an issue when trying to configure redirections on IIS server. I have a website running in IIS and first of all i'd like to:
redirect all the incoming requests for that site from http->https
redirect all the incoming requests for that site if the URL is for example: https: //abc.org to https ://abc.org/loginpage
I set the first rule as explained here: https://www.ssl.com/how-to/redirect-http-to-https-with-windows-iis-10/
And then set the second rule as explained here: IIS 10 URL redirect from one domain to another
But it's still not working. Tried restarting IIS, restarting app pools, website, clearing browser cache...
Thanks!
You can try to use this URL Rewrite rule:
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://example.com/loginpage" redirectType="Found" />
</rule>
</rules>
</rewrite>
You need to modify example.com to abc.org.

How can I redirect IIS request to a specific url

we had an application (http://stellramapps.com/) which was running in server1, now the application has been migrated to server2.
We have done the DNS settings for the request coming to server1 to route to server2.
the IIS redirection rule also has been set with the regular expression = ^http://stellramapps to redirect to http://tdstest/
but still i face the below error
Can’t reach this page
•Make sure the web address http://stellramapps.com is correct
http:// is not included in HTTP_HOST so please try ^stellramapps$ instead of ^http://stellramapps.
Plesease ensure http://tdstest/ can be accessed from the server of stellramapps.
Then please install URL rewrite and ARR
https://www.iis.net/downloads/microsoft/application-request-routing
Finally, you can enable IIS manager->server node->application request routing cache->Server Proxy Settings->Enable Proxy and apply this rule
<rule name="redirect rule" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^stellramapps$" />
</conditions>
<action type="Redirect" url="http://tdstest/{R:0}" />
</rule>

web.config to route all request to index.php except for physical files and directories

im trying to upload a php script to windows iis server
in php script we have a htacess file which routes all the request to index.php so we can have
site.com/something
instead of
site.com/index.php?/something
but it doesnt work on the windows server so i tried to find web.config version here is what i found
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- Quitar los slash '/' del final de la ruta -->
<rule name="RewriteRequestsToPublic">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="/{R:0}" />
</rule>
<!-- Si el archivo o carpeta solicitado no existe, se realiza la petición a través de index.php -->
<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/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
it kinda works , but it doesn't load static files (css , js ) like if i go to
site.com/public/js/jquery.js
i get this error
HTTP Error 500.52 - URL Rewrite Module Error.
The page cannot be displayed because an internal server error has occurred.
Detailed Error Information
Module RewriteModule
Notification SendResponse
Handler StaticFile
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'rule' with unique key attribute 'name' set to 'Imported Rule 1'
Config File \\?\C:\HostingSpaces\phoenarts\site.com\wwwroot\public\web.config
basically it works i need to tell it to ignore link to directory and static files files
The error implies you already have a rule declared with the name Imported Rule 1 somewhere. Try changing the name of the rule in the file indicated in the error.
If you have a web.config file in ~/public and another in the web root both files are merged for requests to your static assets. This sounds like what's happening?
You can use multiple web.configs to configure different paths like this, but you shouldnt duplicate rules between them.
You can also use <location> elements in the root web.config to configure different paths (as an alternative to using multiple web.config files).

IIS Rewrite Rule - redirect specific HTTP page

here is my rule:
<rule name="RedirectHttps04" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="^some-url-here$" />
<add input="{HTTPS}" pattern="^off$" />
</conditions>
<action type="Redirect" url="https://www.example.com/some-url-here" />
</rule>
With the above rule I would like to redirect a specific URL to https and keep all the other ones as they are.
So when user goes to:
www.example.com/some-url-here
http://example.com/some-url-here
http://www.example.com/some-url-here
I would like them to be redirected to:
https://www.example.com/some-url-here
But, after going through many versions and options available here - non of them worked, after reading multiple articles I don't see why the rule above doesn't work (doesn't redirect).
I'm using IIS 8.5.96
More info:
{HTTPS} parameter appears to be always "off"
{HTTP} is either "" for http or "off" for https, but even so the rule doesn't work
I have set to redirect to test.html?p={CACHE_URL} and both appears to take me to test.html?p=http://example.com
The only thing I have that works is a rule which appends parameter at the end if it's not appended, a very ugly hack but ensures user ends up on https :/

Remove parts from url when rewriting

I have a Magento installation and want to rewrite the url and remove index.php and the trailing '/' from it
e.g. rewrite
http://www.domain.com/index.php/ to http://www.domain.com
http://www.domain.com/index.php/customer/account/login/ to http://www.domain.com/customer/account/login
etc etc.
So not for these 2 urls but for all urls.
I currently have this in my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Magento SEO: remove index.php from URL">
<match url="^(?!index.php)([^?#]*)(\\?([^#]*))?(#(.*))?" />
<conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
<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:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
With the above web.config, the urls do not seem to be rewritten at all, but are just kept as-is.
As per my suggestion that thing could not help you.
but as i was faced problem you can follow below things to solve your issue.
step 1: Goto to your site root folder and you can find the htaccess file there.Open it on text editor and find the line #Rewrite Base/ magento. Just replace it with Rewrite Base/
step 2: Then goto your admin panel and enable the Rewrites(set yes for Use Web Server Rewrites). You can find it at System->Configuration->Web->Search Engine Optimization.
step 3: Then goto Cache management page (system cache management ) and refresh your cache and refresh to check the site.
hope this will help you.

Resources