I'm trying to edit my web.config with roadsunknown's code (from this post Remove HTML or ASPX Extension):
<rewrite>
<rules>
<rule name="RewriteASPX">
<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="{R:1}.aspx" />
</rule>
</rules>
</rewrite>
When I add the code I get the following error:
Warning 1 The element 'system.web' has invalid child element 'rewrite'.
I have IIS url rewrite 2.0 installed and have executed the script on this blog (http://blog.vanmeeuwen-online.nl/2013/04/visual-studio-2012-xml-intellisense-for.html) to update it for visual studio 2012. I don't know what else to do to get the web.config code to work.
I'd also be interested in an alternative method to remove the .aspx from my site's urls that doesn't involve IIS.
Not sure about your problem, other than it looks like the module isn't installed. Have you checked the modules section in IIS ?
You could use page routing instead. This describes how to use the page routing mechanism in a webforms app - http://msdn.microsoft.com/en-us/library/vstudio/dd329551(v=vs.100).aspx
Related
After npm run serve everything's working fine. After i deployed my app with API in ASP.NET application doesnt scale at all. I use Router and History. Authentication for annonymous users is enabled and static content is installed. Console doesn't show any errors.enter image description here
Links to screenshots:
Local run
IIS
What do you mean that vue.js not scaling? The second component display abnormally, is it right?
It might be something wrong with Javascript code snippets working.
Did you install the URL Rewrite extension in IIS and add the below rules in the webconfig file?
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" 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>
Here is URL Rewrite extension.
https://www.iis.net/downloads/microsoft/url-rewrite
I followed the Angular2 VS setup from this page-
https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html
The issue is that http://localhost:56428/ gives a 403 (forbidden) error, and the only way to access my index is to navigate to http://localhost:56428/src/index.html.
This is not ideal, and doesn't even work because requests to system.js and other files on this page go straight to the web root.
I'm not sure if I missed a step here but I don't think this is what they intended. How do I make src/ servable at /?
ANSWER FOUND AT
.net web application change root directory
I don't know why the angular site does not mention that.
Try to add base tag:
The tag specifies the base URL/target for all relative URLs in
a document
.
http://www.w3schools.com/tags/tag_base.asp
ANSWER FROM
.net web application change root directory
<configuration>
<system.web>
...
<urlMappings enabled="true">
<add url="~/" mappedUrl="~/src/index.html" />
</urlMappings>
</system.web>
...
<system.webServer>
...
<rewrite>
<rules>
<rule name="Redirect everything to root" 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="/src/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
...
</configuration>
Have you marked your index.html as application start up page?
If not, right click on index.html and click on "Set As Start Page".
I am trying to configure the silex framework and just get an example application working. I am using an IIS server version 7.5 to do so. On the following website it gives me a sample web.config file I should be using. The file is as follows:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Silex Front Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The problem is when trying to navigate to the website I just get the error:
The requested page cannot be accessed because the related
configuration data for the page is invalid.
So essentially IIS says the file is incorrect but I don't have much experience with these files so I don't know if there is a problem. Maybe the file is outdated and the newer doesn't work with newer versions of IIS. There is nothing in the server logs. Anyone come across this problem before?
Turns out I just needed to install the rewrite module for IIS at the following link:
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Suppose you're hosting Wordpress on IIS 7 and you want to activate permalinks. Looking at the codex here, you'll see this example code for the web.config file (located at the root of your WordPress install) to be added in the <system.webServer> tag:
<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>
</rules>
</rewrite>
All is well and the url rewrite rule's conditions correctly ignore existing files and folders present on the system.
However, you may come to a situtation, as I did, where you need to ignore every uri that lies within a certain sub folder, even if there is not a corresponding file on the filesystem. In my case I am hosting a set of WCF services in a subdirectory /Services/ using the <serviceActivations> area of the web.config (at the subdirectory) in the form:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./AccountService.svc" service="MyAssembly.Services.AccountService"/>
</serviceActivations>
</serviceHostingEnvironment>
Navigating to the AccountService.svc will cause a 404 not found.
How can you handle this situation? Below I have posted my specific solution, but there are other ways to achieve this. Also, a general case solution is still elusive, so the question remains, how can you handle this situation generally?
Below I've provided my solution as a complete newbie to the world of URL Rewrite. The solution is specific to a particular folder.
To solve my problem is was necessary to add an additional condition to the rewrite rules:
<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" />
<add input="{REQUEST_URI}" pattern="^/Services/.*" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
In your case, substituting your folder name where I have "Services" will suffice.
What if you wanted to do this for any directory or directory hierarchy, such that if the directory hierarchy exists, then let any url containing that directory hierarchy pass through without being rewritten. My attempt at this has thus far centered around matching the portion of the url which contains the directory hierarchy and using a back reference to detect if this directory exists:
<rule name="ignoreSubDirectoryURIs" stopProcessing="true">
<match url="(.*)/.*\..*" ignoreCase="false" />
<conditions>
<add input="{APPL_PHYSICAL_PATH}\{R:1}\" matchType="IsDirectory" />
</conditions>
<action type="None" />
</rule>
This rule is added first so that if it is successful the other rewrite rule is not interpreted.
Problems: while {APPL_PHYSICAL_PATH} is a directory, I haven't been able to get any combination of {APPL_PHYSICAL_PATH} and a sub directory to resolve correctly. The other problem is with nested directories, where the {R:1} will return dir1/dir2, instead of dir1\dir2, which may make this not work for the nested case.
Reading the URL Rewrite Reference has been instructive if not complete
I have a ASP.NET MVC3 website located at http://mydomain.com/mymvcapp/. However, the root of the webiste (mydomain.com) contains a WordPress site running PHP. Therefore, I put the following IIS URL Rewrite rule to allow WordPress to function correctly via its rewriting mechanisms:
<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>
So with this rule in place my WordPress functions perfectly, however, my MVC rewriting does NOT work. How would I alter this rule to allow both WordPress and MVC (under the /mymvcapp/ folder) to coexist nicely?
Figured it out on my own. Regex is probably one of the most powerful YET complicated / confusing technologies there is. But in this case the patternSyntax flag was set to Wildcard, not Regex, which caused my confusion. Hope this helps someone else out there! =]
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions logicalGrouping="MatchAll">
<add input="{PATH_INFO}" pattern="/mymvcapp/*" negate="true" />
<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>
This is one of the very few posts anywhere that talks about making WordPress and ASP.NET coexist nicely in an IIS setup. So Kudos for that.
I was thinking to post this as comment to either your original question or the answer, but I chose to write an "answer" only because this is an honest question and I need some formatting capabilities.
I have multiple ASP.NET apps running on by site. In particular the root website is running an MVC4 app.
Since I cannot have WordPress installed at the root, my plan was to have it on its own app folder http://mydomain.com/wordpress/ and then have a URL-rewrite rule that to do the following (using peudo-code):
blog.mydomain.com/{path} --> mydomain.com/wordpress/{path}
I've only caused a mess with this approach and have not been successful using pretty permalinks, sometimes getting into redirect-loops and other times breaking links to .css files, admin pages, etc...
Have you ever given this a thought, i.e., having wordpress as a subapp instead and do sub-domain URL-rewriting?!?!
I had a similar situation but I had no need to edit my web.config file. Instead I followed instructions here at https://wordpress.org/support/article/giving-wordpress-its-own-directory/ where this is documented.
At point 7) within Moving WordPress process to a subfolder Method II (With URL change) you find options for a IIS installation.