Skip to content

Instantly share code, notes, and snippets.

@fredrik-lundin
Created March 28, 2017 16:51
Show Gist options
  • Save fredrik-lundin/b528e1dd8faacc86c360f62731309dec to your computer and use it in GitHub Desktop.
Save fredrik-lundin/b528e1dd8faacc86c360f62731309dec to your computer and use it in GitHub Desktop.
web.config rewrite all requests to index.html
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="redirect all requests" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
@ezetojo
Copy link

ezetojo commented Oct 1, 2019

Thanks

@jorgesanabria
Copy link

Thanks

@mrtyvz61
Copy link

mrtyvz61 commented Jul 8, 2020

thats worked babuş love from Turkey

@iomariani
Copy link

❤️

@amendez1000
Copy link

Thanks for your help. It works for me.

@sumanthrakesh
Copy link

Thank you :)

@andreas-kater
Copy link

Thank you!

@BarakaElias
Copy link

Thank you very much

@SidCrow87
Copy link

Hi, I'm really not a dev. needed this code in my website for a temporary redirection.

What should I put as "REQUEST_FILENAME}" Should I put Index.html(It's where I want the redirection to go) or should I put all the other .html that I dont want accessible? thanks!

@AndrewShepherd
Copy link

Dude you are awesome.

@PeterO73Git
Copy link

PeterO73Git commented Nov 6, 2023

Hi, I'm really not a dev. needed this code in my website for a temporary redirection.

What should I put as "REQUEST_FILENAME}" Should I put Index.html(It's where I want the redirection to go) or should I put all the other .html that I dont want accessible? thanks!

You don't need to change that, REQUEST_FILENAME is just a variable that represents whatever file has been requested. It will match requests to all other pages and make them inaccessible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment