Skip to content

Instantly share code, notes, and snippets.

View rsisco's full-sized avatar

Richard Sisco rsisco

  • 22:15 (UTC -05:00)
View GitHub Profile
@mandatoryhashtags
mandatoryhashtags / 750_error
Last active July 16, 2020 13:26
Fastly VCL for www -> non-www domain
if (obj.status == 750) {
set obj.http.Location = obj.response;
set obj.status = 301;
return(deliver);
}
@mandatoryhashtags
mandatoryhashtags / fastly-csv-to-json.phar
Created January 7, 2020 21:07
Phar file to to create JSON for fastly redirects given CSV old_url,new_url expects headers to be line 0
<?php
$csvFile = $argv[1];
$csvData = null;
$mappedData = [];
$fileToSave = 'fastly_redirects.json';
if ($csvFile === null) {
return 'Please provide a valid CSV file';
}
@mttjohnson
mttjohnson / test_http_redirects.sh
Last active January 31, 2024 22:31
Testing HTTP Redirects
# The check_url recursive function
check_url() {
THIS_URL="${1}"
HTTP_RESP_CODE=$(curl -ksI "${THIS_URL}" | grep -i 'HTTP/' | cut -d' ' -f 2)
echo "${THIS_URL} -> ${HTTP_RESP_CODE}"
if [ "${HTTP_RESP_CODE}" == "301" ] || [ "${HTTP_RESP_CODE}" == "302" ]
then
HTTP_LOC=$(curl -ksI ${1} | grep -i 'Location: ' | cut -d'_' -f 2)
HTTP_REDIRECT=$(echo "${HTTP_LOC}" | tail -c +11 | tr -d '\r' | tr -d '\n')