Is there anyway I can change the website from ging from .co.uk to .com in the web.config file - wordpress

I have put in this http redirectin the web config file but I keep getting a redirection loop. The website is a wordpress website and is being hosted on IIS7.5, it may also be worth metioning that I have a plug in called really simple ssl installed to handle the https redirects.
I will attach my web.config file below
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
<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="index.php" /></rule>
<rule name="WordPress: http://www.google.com"
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></rules>
</rewrite>
<httpRedirect enabled="true" destination="http://www.google.com" httpResponseStatus="Permanent" />
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="xmlrpc.php" />
</denyUrlSequences>
<requestLimits maxAllowedContentLength="50000000" />
</requestFiltering>
</security>
<handlers>
</handlers>
</system.webServer>
</configuration>

Related

Cannot find equivalent of system.web.compilation.tempDirectory for system.webServer

In web.config, what is the equivalent of system.web>compilation[tempDirectory] attribute but using the more up to date system.webServer instead of system.web?
Here is what I need to add to my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation tempDirectory="W:\vhosts\mysite.com\tmp" />
</system.web>
</configuration>
However, my current web.config relies on system.webServer, not system.web and adding the attribute results in an internal server error 500.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/>
<rewrite>
<rules>
<rule name="Angular Routes" 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="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
compilation[tempDirectory] is depending on system.web, so you cannot add it in system.webServer.
But system.web and system.webServer can both exist in web.config. They won't lead to conflict.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation tempDirectory="W:\vhosts\mysite.com\tmp" />
</system.web>
<system.webServer>
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/>
<rewrite>
<rules>
<rule name="Angular Routes" 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="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Angular Routing in IIS server

I have an Angular 4 app in a IIS server, in the same server there is a .NET Web API. They are in diferents folders: angular app is in "/wwwroot/angular/" and web api in "/wwwroot/api/". When I do a request to web api, it works successfully, but when I try to navigate to an URL different to index.html using the Routing Module in angular app I get this message:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Also, I have two Web.Config files -one in each folder-.
My Angular Web. Config is:
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" 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="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
Web.config of WEB API
<configuration>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</configuration>
I researched in some questions like:
stackoverflow.com/questions/49833141/blank-page-when-publishing-angular-5-net-core-web-api
and
stackoverflow.com/questions/42865084/redirect-unknown-requests-to-index-html-in-springboot
But they doesn't work to me.
Anybody help me on this.
Thanks in advance.
The solution was move all the Angular files to root, at index.html I left <base href="/"> and make the web.config like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="^(.*)$" />
</rewriteMaps>
<rules>
<rule name="Angular Route" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="/api(.*)$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="?" />
</authorization>
</security>
</system.webServer>
</configuration>
In your web.config change <action type="Rewrite" url="/FIN360" /> and in your index.html from the <base href="/"> remove the / Try this else change <base href="./"> OR <base href="/FIN360">

Second Wordpress installation on IIS server

I currently have a working wordpress installation in my server root, but now I'm adding another wordpress site to subfolder "new-site".
It's an IIS server, so the web.config file should have this in the root directory, according to wordpress:
<configuration>
<system.webServer>
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
The problem I'm facing now: How to modify the root's web.config file (below) so that the WP installation in /new-site works fine. (It's working fine on my localhost and I've changed the URLs in wp-options. The homepage on new-site looks fine but if you click on any link it'll be an error page of the root site.) Thanks!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
<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="index.php" />
</rule>
<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>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
<add value="index.html" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="aboutus.html" />
</files>
</defaultDocument>
<handlers>
<remove name="PHP53_via_FastCGI" />
<remove name="AboMapperCustom-1045478" />
<add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>
</system.webServer>
</configuration>
Solved. In the web.config in the subfolder, add <clear /> so it won't be affected by the root's rule(s).
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
Source: http://forums.iis.net/post/1883731.aspx

Configure IIS URL Rewrite module for AngularJS HTML5Mode Still Not Working

I have searched at found some info on configuring IIS URL Rewrite module to work with AngularJS HTML5Mode and even tried the info I found on another question:
How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode?
I've made the changes to my IIS as displayed in the question found in the link above and set the base URL and the site works when I visit the root site (i.e. http: //localhost/appname/). All of my views and the routing works fine.
However; when I try to visit a specific URL (i.e. http: //localhost/appname/about) in a new tab or browser window, I get a 404. Is there something else I'm missing???
I'm running Windows 7, IIS 7 with the URL Rewrite Module installed.
** I had to space the protocol out to allow the example URL to be accepted.
Install this extension: https://www.iis.net/downloads/microsoft/url-rewrite
And add this to web.config under system.webServer
<rewrite>
<rules>
<clear />
<rule name="Html5Mode" enabled="true" stopProcessing="true">
<match url="^(.+)$" negate="true" />
<conditions>
<add input="{REQUEST_URL}" pattern="^(.+)$" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" logRewrittenUrl="true"/>
</rule>
<rule name="AngularJS" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
Here is the full web.config including serving static files.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Html5Mode" enabled="true" stopProcessing="true">
<match url="^(.+)$" negate="true" />
<conditions>
<add input="{REQUEST_URL}" pattern="^(.+)$" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" logRewrittenUrl="true"/>
</rule>
<rule name="AngularJS" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
<handlers>
<clear />
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
<staticContent>
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

Wordpress url rewriting does not work on iis7

I have a Wordpress website running on IIS7.
I had a big problem because all my url except the home page contain index.php.
My home page : www.mywebsite.com
Others : www.mywebsite.com/index.php/post1, www.mywebsite.com/index.php/post2 and so..
I'd like to use the url rewriting mode of IIS7. My web host told me that the rewriting module is activated.
I don't know what to write in web.config file. I've tried :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
My url does not change !
and this :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Supprimer index.php">
<match url="^index.php/([_0-9a-z-]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="{R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I've also tried:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<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="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Always does not work.
Could you help me to remove index.php in the url please ?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed"/>
<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="index.php/{R:0}"/></rule>
<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>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear/>
<add value="index.php"/>
</files>
</defaultDocument>
</system.webServer>
</configuration>

Resources