I have a web.config file set up on an IIS box, which sends all web requests to a single index.php file, with two exceptions, which go to their intended destinations, as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="redirect all requests" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/app/Library/editor/$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/app/Library/editor$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/its/$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/its$" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The exceptions work fine, in that http://servername/its, or http://servername/its/ serves up the correct page, but when there are parameters included in the request, eg, http://servernae/its/?value1=value2, it returns a page not found error.
I have a feeling that it is something obvious I have missed, but what do I need to add/change to get http://servernae/its/?value1=value2 to work as expected?
Regards
Related
I use the following rule to change the path of every image file to .webp. Except for the subdirectories typo3, fileadmin and upload. That works fine.
But the website also loads external images. These URLs shouldnt be changed to .webp
So I added
another condition
<add input="{HTTP_HOST}" pattern="mydomain.com" ignoreCase="true" />
In the rule test interface in IIS it works fine. I use an imagepath from my own domain. The rule test says the pattern fits. If I use an external image path, the pattern did not fit.
BUT if I load a page on my website with different images from different URLs all paths are changed to .webp and this means, that the external ones are not found (404).
How can I make this work?
<rule name="Webp" enabled="true">
<match url="(.+)\.(jpe?g|png)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_ACCEPT}" pattern="image/webp" ignoreCase="false" />
<add input="{HTTP_HOST}" pattern="mydomain.com" />
<add input="{DOCUMENT_ROOT}/{R:0}.webp" matchType="IsFile" />
<add input="{REQUEST_URI}" pattern="typo3/" negate="true" />
<add input="{REQUEST_URI}" pattern="fileadmin/" negate="true" />
<add input="{REQUEST_URI}" pattern="uploads/" negate="true" />
</conditions>
<serverVariables>
<set name="ACCEPTS_WEBP" value="true" />
</serverVariables>
<action type="Rewrite" url="{R:0}.webp" appendQueryString="false" logRewrittenUrl="true" />
</rule>
</rules>
<outboundRules rewriteBeforeCache="true">
<rule name="jpg to webp" preCondition="ResponseIsHtml" enabled="true">
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="mydomain.com" ignoreCase="true" />
<add input="{REQUEST_URI}" pattern="typo3/" negate="true" />
<add input="{REQUEST_URI}" pattern="fileadmin/" negate="true" />
<add input="{REQUEST_URI}" pattern="uploads/" negate="true" />
</conditions>
I have something new. The external images (and more information) are a response to an AJAX call like this from my own domain.
https://www.example.org:443/index.php?tx_jsdshopware_searchview%5B__referrer%2D%5B%40extension%5D=JsdShopware&tx_jsdshopware_searchview%5B__referrer%5D%5B%40controller%5D=SearchView&tx_jsdshopware_searchview%5B__referrer%5D%5B%40action%5D=list&tx_jsdshopware_searchview%5B__referrer%5D%5Barguments%5D=YTowOnt9af44e2e88d7b23601117be0ff9656fd98a839a38&tx_jsdshopware_searchview%5B__referrer%5D%5B%40request%5D=%7B%22%40extension%22%3A%22JsdShopware%22%2C%22%40controller%22%3A%22SearchView%22%2C%22%40action%22%3A%22list%22%7D2eb573bf2f44341434ca68abb64479da78fd5613&tx_jsdshopware_searchview%5B__trustedProperties%5D=%7B%22searchword%22%3A1%2C%22action%22%3A1%7D0a3b9fd37c893b374a4bb4c2daaa7dd2afa90ccc&tx_jsdshopware_searchview%5Bsearchword%5D=footest&type=4321&tx_jsdshopware_searchview%5Baction%5D=ajaxCall&_=13212131
Can I exclude the rewriting of the filenames my filtering for "ajax" ? I have no experience with these technology.
I have one url which having ./ [period & slash] at the end of parameter. I want to redirect that url with different location but its not even detecting in rules. I am using IIS. I want to configure this on web.config
http://somesitename.com/mypage/teachers-manual./sku/8772
needs to redirect on
http://somesitename.com/mypage/teachers-manual/sku/8772
Though I have tried solution given on Here but its not even working. But if I use same thing instead of Redirect with Rewrite then Rule start working. Not sure why its not working for "Redirect".
<rule name="Trailing Dots and spaces" stopProcessing="true">
<match url="^mypage\/(.*)([\.\s]+)\/(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="/index.cfm/{R:1}/{R:2}/{R:4}" appendQueryString="true" />
</rule>
Actually when I tried to write rule then url which having ./ is also not working.[ http://somesitename.com/mypage/teachers-manual./sku/8772 ]
<rule name="Trailing Dots and spaces1.1" stopProcessing="true">
<match url="^(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://somesitename.com/newpage.html" />
</rule>
Not sure where its wrong.
Just got more information on Post & Haacked Said for it.
so I have modified file as follows and now its perfectly working for me.
<configuration>
<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Trailing Dots and spaces1.1" stopProcessing="true">
<match url="^(.*)/(.*)\.\/(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="/{R:1}/{R:2}/{R:3}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
.... etc
On a server there are two webapps, a wordpress website, and a 'standalone' website in a subdirectory.
Both apps need a rewrite for index.php, and for wordpress this was done automatically, but now I also need a rewrite for the other app in the subdirectory.
To further clarify:
http://www.example.com/contact should redirect to http://www.example.com/index.php/contact
http://www.example.com/subfolder/contact should redirect to http://www.example.com/subfolder/index.php/contact
It seems like a rather simple thing to do, but I can't seem to figure it out...
This is the web.config I have right now, how can I fix this?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear/>
<add value="index.php"/>
<add value="Default.htm"/>
<add value="Default.asp"/>
<add value="index.htm"/>
<add value="index.html"/>
<add value="iisstart.htm"/>
<add value="default.aspx"/>
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
<rule name="standalone" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I am running the config below to rewrite for example
http://www.phusewebdesign.co.uk/blog/Get-in-touch
to
http://www.phusewebdesign.co.uk/index.php?s=blog&p=Get-in-touch
but I get a 404 error, I am missing something simple I am sure but can't fimd the answer on google or here
thanks
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL2" stopProcessing="true">
<match url="^([^/]+)/([^/]+)/?$" />
<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="index.php?s={R:1}&p={R:2}" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/?$" />
<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="index.php?p={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I've got a rule that rewrites URLs unless a physical file exists (so static files can be returned) - however for some reason the rules get rewritten anyway, to much frustration.
Here's my Web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Front Page">
<match url="/?" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/Home/FrontPage" />
</rule>
<rule name="Map Everything" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="EntryPoint.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
Ah, it turns out the "Front Page" rule was the problem, and the rule "/?" was matching everything when I should have used "^$" instead.
After fixing that, the IsFile/IsDirectory rules were being respected.