Skip to content

Instantly share code, notes, and snippets.

View Swimburger's full-sized avatar
🍔
Creating full snack content

Niels Swimberghe Swimburger

🍔
Creating full snack content
View GitHub Profile
@Swimburger
Swimburger / IISRewriteRules.config
Created October 8, 2018 00:00
Remove trailing slash redirect IIS web.config
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
@Swimburger
Swimburger / IISRewriteRules.config
Created October 8, 2018 00:02
Add trailing slash to URL redirects IIS web.config
<rule name="Add trailing slash" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}/" />
</rule>
@Swimburger
Swimburger / IISRewriteRules.config
Created October 8, 2018 00:05
Redirect to lowercase URL redirect IIS web.config
<rule name="Convert to lower case" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
@Swimburger
Swimburger / robots.txt
Created October 10, 2018 02:51
Robots.txt example with sitemap
Sitemap: https://swimburger.net/sitemap.xml
User-agent: *
Disallow: /umbraco
@Swimburger
Swimburger / Robots.chtml
Last active September 20, 2019 21:43
Dynamic Robots.cshtml robots.txt file for Umbraco, learn more at https://swimburger.net/blog/umbraco/crawling-through-umbraco-with-robots
@inherits UmbracoTemplatePage
@{
Layout = null;
umbraco.library.ChangeContentType("text/plain");
var rootUrl = Request.Url.GetLeftPart(UriPartial.Authority);
}Sitemap: @string.Format("{0}{1}", rootUrl, "/sitemap.xml")
User-agent: *
Disallow: /umbraco
@Swimburger
Swimburger / CrawlSite.ps1
Last active June 27, 2023 22:24
Crawl your website links and images to find broken links/images using PowerShell
Param(
[Parameter(Mandatory=$true)]
[string] $Url,
[Parameter(Mandatory=$true)]
[int] $MaxPages,
[bool] $IncludeImages = $true,
[bool] $StayOnDomain = $true,
[bool] $IgnoreFragments = $true)
Add-Type -AssemblyName System.Web
Function CrawlSitemap
{
Param(
[parameter(Mandatory=$true)]
[string] $SiteMapUrl
);
$SiteMapXml = Invoke-WebRequest -Uri $SiteMapUrl -UseBasicParsing -TimeoutSec 180;
$Urls = ([xml]$SiteMapXml).urlset.ChildNodes
ForEach ($Url in $Urls){
Function PurgeAllCloudflareCache{
Param(
[parameter(Mandatory=$true)]
[string] $AdminEmail,
[parameter(Mandatory=$true)]
[string] $ApiKey,
[parameter(Mandatory=$true)]
[string] $ZoneId
);
Param(
[Parameter(Mandatory = $true)]
[string] $ResourceGroupName,
[Parameter(Mandatory = $true)]
[string] $AppServiceName,
[Parameter(Mandatory = $true)]
[string] $SubscriptionId,
[Parameter(Mandatory = $true)]
[string] $RulePriority
)
Get-ChildItem -Directory | ForEach {$_.FullName + (" {0:N2} MB" -f ((Get-ChildItem $_.FullName -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB))}