Using Htaccess files on iis (windows 10) - iis

I cannot find any information on how to perform URL Rewriting on IIS (windows 10). I develop websites on windows but have a linux server which uses a htaccess file for URL Rewriting.
The issue here is, I find it far too time consuming to manually enter rules into iis with the standard url rewriter. You can't just write them out in a text document like you can on a Linux server with htaccess files!?
Is there some way to use a htaccess file, web.config file, or ionic's isapi (or other) url rewriter on iis (windows 10) to write out all of my websites url rewriting rules? It seems that none of those software packages have support for this operating system/the latest IIS.
Thanks!

I had the same issue, but fortunately there is a handy shortcut in the IIS URL Rewrite 2.1 module that converts .htaccess files directly into the equivalent web.config;
In IIS, double-click on the URL Rewrite module
In the Actions pane, click 'Import Rules'
Paste the contents of your .htaccess file into the 'Rewrite rules' text box
Viola, your .htaccess rules are converted into IIS web.config rules
There is an article here: https://blogs.msdn.microsoft.com/azureossds/2015/04/23/converting-apache-htaccess-rules-to-iis-web-config-using-iis-manager-for-azure-websites/ that provides an illustrated step-by-step guide to the process. The article is specifically aimed at Azure, but I use IIS on Windows 10 for localhost dev and it works just fine.

All rules for the IIS URL Rewrite module are stored in text files, either your local web.config or the global ApplicationHost.config file. You can also use a custom config file like rewrite.config and include it in your web.config like:
<system.webServer>
<rewrite>
<rules configSource="rewrite.config" />
</rewrite>
</system.webServer>
IIS url rewriting is the same for all IIS Version since 7.0 on Server 2008 and nothing had changed in Windows 10, there are lots of resources about it out there.

Related

IIS - tempory config file overwrite DefaultAppPool.config

I'm working aroung IIS config files.
I want add some IIS IP address restrictions at server level, that spread over all the IIS appPolls
If I work with IIS Manager all work fine, I'm able to add any config settings. But if I want modify/add them directly on .config file it is no possible.
I can see that the settings made by IIS Manager are written on a temporary .tmp file under C:\inetpub\temp\appPools and then overwritten on DefaultAppPool.config under C:\inetpub\temp\appPools\DefaultAppPool
If I try to manual modify DefaultAppPool.config it don't take effect on IIS Manager and if I make any changes on IIS Manager it is overwritten. If I try to manual modify the tmp config under C:\inetpub\temp\appPools I'm informed that the file is in use.
I've also try to work with applicationHost.config under C:\Windows\System32\inetsrv\config, but it does not seem to match the configuration displayed on IIS Manager.
So how can I edit the IIS configuration file manually at the server level?
I've to add a lot of IP restrictions and the only way is to add them directly on .config file.
Very thanks for any help
That is the temporary file. if you want to change the iis configuration at the server level then you could modify the iis applicationhost.config file.
ApplicationHost.config is the root file of the configuration system when you are using IIS 7 and above. It includes definitions of all sites, applications, virtual directories and application pools, as well as global defaults for the web server settings (similar to machine.config and the root web.config for .NET Framework settings).
Open notepad as administrator and open applicationhost.config
add below code in the config file:
<ipSecurity allowUnlisted="true">
<add ipAddress="192.168.2.52" allowed="true" />
</ipSecurity>
https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/introduction-to-applicationhostconfig

Is there a way to allow .htaccess file in IIS windows hosting?

I'm using windows shared hosting with a wordpress site, and I used a theme that create .htaccess file which is not allowed in the windows hosting.
I don't need to simulate the .htaccess code, I just want to allow it to be existed not to run.
Is there a way to allow .htaccess file to be existed in IIS windows shared hosting?
for example: is there a way to allow it from web.config?
or a way to delete it automatically when existed?

need to write htaccess file in windows server 2008

I need to write htaccess file in windows server 2008.I created a htaccess file in localhost which works fine.
Need to know Where to create htaccess file in windows server 2008 R2.
I surffed,I that told to create web.config in IIS.
Now I need to know where to create web.config in windows serer 2008 R2
Here is the possible solution for issue.
If possible than you can covert your htaccess to web.cofig file. It's IIS compatible and readable file.
Click here.

Legacy ASP site issue

I'm dealing with an issue where there was a site setup, and the default.htm used an iframe which pointed to an ASP directory. It seems like the ASP directory isn't readable and not processed - is there anything special that needs to be done to the ASP directory like permissions-wise?
wwwroot/sitename
<iframe src="ASP/file.asp"></iframe>
wwwroot/sitename/ASP/file.asp exists, and several other asp files but they aren't getting referenced by the iframe.
Update: I'm getting a 404..
The page cannot be found
I think I have to create a virtual directory and name it ASP. I never use IIS though - does anyone know how this works? And would I need to restart IIS after creating the virtual directory?
Update #2: More info..
Execute permissions: Scripts Only
Application name: asp
For Authentication Methods, "Integrated Windows authentication" is checked
Local Path: Read
Update #3: I can access asp/file.htm file fine. Can anyone provide code for a simple test I could do to see if its working properly ( I have no ASP/VBScript experience )..
one of the top of the pages contains <%# LANGUAGE="VBSCRIPT"%>
Is this IIS6 by any chance? In IIS, under Web Sites there is a folder called Web Service Extensions. Make sure Active Server Pages are set to Allow and not Prohibited!
When you create a virtual directory for an ASP site in IIS, you have to make sure it is allowed to execute scripts. What version of IIS are you using? In 5.0 and 6.0, there should be a checkbox Run Scripts (such as ASP). Make sure that's checked.
Try putting a test.html file in the root directory of the site and then try to open it through wwwroot/sitename/asp/test.html - .html files won't be processed by asp.dll and so should display if the site is setup correctly even if there is some kind of asp.dll problem.
If you can't see a html file then I guess you will need to configure the website in IIS (not sure if a virtual directory is necessary from the information given) - check the 'home' tab to see if the path to the application is correct first.
If you can see the html file then I'd guess that asp is not properly installed (but that is a guess).

I cannot access files in IIS 6

I have a default IIS 6 install and I can access only .html files. If I create a html file I can see it on the browser. Any other files like ini for example are not visible (404). Any idea on what can be the issue?
Check the web service extensions are enabled (in IIS below the websites is a folder for them) for the content you are trying to share.
Check that the handler mappings is setup correctly (on the website properties)
This may help :
IIS & ASP.NET blocking file

Resources