Skip to content

Instantly share code, notes, and snippets.

@Jlaird
Created May 24, 2021 14:38
Show Gist options
  • Save Jlaird/b8ea55cdd1ea55cc25cce60c3dd96e3b to your computer and use it in GitHub Desktop.
Save Jlaird/b8ea55cdd1ea55cc25cce60c3dd96e3b to your computer and use it in GitHub Desktop.
const redirects =
{
'/advanced-engine/ase-l3-study-guide-hybrid-electric-vehicle-specialist-test-prep': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-L3-Light-Duty-Hybrid-Electric-Vehicle-Specialist-Certification-Preparation-by-Motor-Age-Training.aspx',
'/advanced-engine/l1-advanced-engine-performance-specialist': 'ttps://passthease.motoragetraining.com/Content/ASE-Test-Prep-L1-Advanced-Engine-Performance-Certification-Preparation-by-Motor-Age-Training.aspx',
'/advanced-engine/l2-electronic-diesel-engine-diagnostic-specialist': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-L2-Medium-Heavy-Vehicle-Electronic-Diesel-Engine-Certification-Study-Guide-by-Motor-Age-Training.aspx',
'/ase-advanced-engine-l-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
'/ase-advanced-engine-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
'/ase-c1-practice-test-service-consultant-training': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-C1-Automotive-Service-Consultant-Certification-Test-Prep.aspx',
'/ase-school-bus-certification': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=44',
'/ase-x1-practice-test-exhaust-systems-certification': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-X1-Exhaust-Systems-Certification-Test-Prep.aspx',
'/car-light-truck-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=39',
'/car-light-truck/a1-a9-packages': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A1-A9-Car-and-Light-Truck-Certification-Study-Guides.aspx',
'/car-light-truck/a1-engine-repair': 'https://passthease.motoragetraining.com/content/ASE-Test-Prep-A1-Engine-Repair-Certification.aspx',
'/car-light-truck/a2-automatic-transmission-transaxle': 'https://passthease.motoragetraining.com/content/ASE-Test-Prep-A2-Automatic-Transmission-Certification.aspx',
'/car-light-truck/a3-manual-drivetrain-axles': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A3-Manual-Drivetrain-and-Axles-Certification.aspx',
'/car-light-truck/a4-steering-and-suspension': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A4-Suspension-and-Steering-Certification.aspx',
'/car-light-truck/a5-brakes': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A5-Brakes-Certification.aspx',
'/car-light-truck/a6-electronic-electrical-systems': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A6-Electrical-Electronic-Systems-Certification.aspx',
'/car-light-truck/a7-heating-ac': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A7-Heating-and-AC-Certification.aspx',
'/car-light-truck/a8-engine-performance': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A8-Engine-Performance-Certification.aspx',
'/car-light-truck/a9-light-vehicle-diesel-engines': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-A9-Light-Diesel-Engines-Certification.aspx',
'/collision-repair': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=42',
'/collision-repair/b-series-packages': 'https://passthease.motoragetraining.com/Content/ASE-Study-Guides-B2-B6-B-Series-Collision-Repair-Books-Set.aspx',
'/collision-repair/b2-paint-refinishing': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-B2-Painting-and-Refinishing-Certification-Book-by-Motor-Age-Training.aspx',
'/collision-repair/b3-non-structural-analysis-damage-repair': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-B3-Non-Structural-Analysis-and-Damage-Certification-by-Motor-Age-Training.aspx',
'/collision-repair/b4-structural-analysis-damage-repair': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-B4-Structural-Analysis-and-Damage-Certification-by-Motor-Age-Training.aspx',
'/collision-repair/b5-mechanical-electrical-components': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-B5-Mechanical-and-Electrical-Components-Certification-Study-Guide-by-Motor-Age-Training.aspx',
'/collision-repair/b6-damage-analysis-estimating': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-B6-Damage-Analysis--Estimating-Certification-Study-Guide-by-Motor-Age-Training.aspx',
'/course-series/advanced-engine-l-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
'/course-series/master-packs': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=51',
'/course-series/medium-heavy-truck-service-t-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=43',
'/course-series/parts-specialist-p-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=49',
'/course-series/performance': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
'/course-series/school-bus-service-s-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=44',
'/course-series/specialty-books-c1-e2-f1-x1': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
'/e2-electrical-electronic-systems-installation-repair': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-E2-Electrical-Electronic-Systems-Installation-and-Repair-Certification.aspx',
'/f1-alternative-fuels-compressed-natural-gas': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-F1-Light-Vehicle-Compressed-Natural-Gas-Certification-by-Motor-Age-Training.aspx',
'/g1-practice-test-auto-maintenance-and-light-repair': 'https://passthease.motoragetraining.com/Content/ASE-Test-Prep-G1-Auto-Maintenance-and-Headlight-Repair-Certification-Study-Guide.aspx',
'/l-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
'/master-pack/MAT1': 'https://passthease.motoragetraining.com/Content/ASE-Study-Guides-Set-A1-A9-L1-and-P2-Motor-Age-Training-Master-Pack-1.aspx',
'/master-pack/MAT2': 'https://passthease.motoragetraining.com/Content/ASE-Study-Guides-A1-A9-L1-X1-P2-and-C1-Motor-Age-Training-Master-Pack-2.aspx',
'/master-packs': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=51',
'/medium-heavy-truck': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=43',
'/medium-heavy-truck-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=43',
'/medium-heavy-truck/t1-gasoline-engines': 'https://passthease.motoragetraining.com/Content/T1-Study-Guide-ASE-Test-Prep-for-Gasoline-Engines-Certification.aspx',
'/medium-heavy-truck/t2-diesel-engines': 'https://passthease.motoragetraining.com/Content/T2-Study-Guide-ASE-Test-Prep-for-Diesel-Engines-Certification.aspx',
'/medium-heavy-truck/t3-drivetrain': 'https://passthease.motoragetraining.com/Content/T3-Study-Guide-ASE-Test-Prep-for-Drivetrain-Certification.aspx',
'/medium-heavy-truck/t4-brakes': 'https://passthease.motoragetraining.com/Content/T4-Study-Guide-ASE-Test-Prep-for-Brakes-Certification.aspx',
'/medium-heavy-truck/t5-steering-suspension': 'https://passthease.motoragetraining.com/Content/T5-Study-Guide-ASE-Test-Prep-for-Suspension-Steering-Certification.aspx',
'/medium-heavy-truck/t6-electrical-electronic-systems': 'https://passthease.motoragetraining.com/Content/T6-Study-Guide-ASE-Test-Prep-for-ElectricalElectronic-Systems-Certification.aspx',
'/medium-heavy-truck/t7-heating-ventilation-ac': 'https://passthease.motoragetraining.com/Content/T7-Study-Guide-ASE-Test-Prep-for-Heating-Ventilation-AC-Certification.aspx',
'/medium-heavy-truck/t8-preventative-maintenance-inspection': 'https://passthease.motoragetraining.com/Content/T8-Study-Guide-ASE-Test-Prep-for-Preventive-Maintenance-Inspection-PMI-Certification.aspx',
'/p-series': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=49',
'/parts-specialist': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=49',
'/parts-specialist/p1-medium-heavy-duty-truck-dealership-parts-specialist': 'https://passthease.motoragetraining.com/Content/P1-Study-Guide-ASE-Test-Prep-for-MediumHeavy-Truck-Dealership-Certification-Test-Prep.aspx',
'/parts-specialist/p2-automobile-parts-specialist': 'https://passthease.motoragetraining.com/Content/P2-Study-Guide-Automobile-Parts-Specialist-Certification-ASE-Test-Prep.aspx',
'/parts-specialist/p4-general-motors-parts-consultant': 'https://passthease.motoragetraining.com/Content/P4-Study-Guide-ASE-Test-Prep-for-General-Motors-Parts-Consultant-Certification-Test-Prep.aspx',
'/school-bus/ase-certification-s-series-package': 'https://passthease.motoragetraining.com/Content/ASE-Study-Guides-S1-S7-S-Series-School-Bus-Service-ASE-Test-Prep-Set.aspx',
'/school-bus/s1-body-systems-special-equipment': 'https://passthease.motoragetraining.com/Content/S1-Study-Guide-ASE-Test-Prep-for-Body-Systems-and-Special-Equipment-Certification-by-Motor-Age-Training.aspx',
'/school-bus/s2-diesel-engines': 'https://passthease.motoragetraining.com/Content/S2-ASE-Test-Prep-ASE-School-Bus-Diesel-Engines-Certification-by-Motor-Age-Training.aspx',
'/school-bus/s3-drivetrain': 'https://passthease.motoragetraining.com/Content/S3-ASE-Test-Prep-ASE-School-Bus-Drive-Train-Certification.aspx',
'/school-bus/s4-brakes': 'https://passthease.motoragetraining.com/Content/S4-ASE-Test-Prep-ASE-School-Bus-Brakes-Certification.aspx',
'/school-bus/s5-suspension-steering': 'https://passthease.motoragetraining.com/Content/S5-ASE-Test-Prep-ASE-School-Bus-Suspension-Steering-Certification.aspx',
'/school-bus/s6-electrical-electronic-systems': 'https://passthease.motoragetraining.com/Content/S6-ASE-Test-Prep-ASE-School-Bus-ElectricalEletronic-Systems-Certification.aspx',
'/school-bus/s7-air-conditioning-systems-controls': 'https://passthease.motoragetraining.com/Content/S7-ASE-Test-Prep-ASE-School-Bus-Light-Duty-HybridElectrical-Vehicle-Specialist-Certification.aspx"',
'/site-map': 'https://passthease.motoragetraining.com/site-map.xml',
'/specialty-books-c1-e2-f1-x1': 'https://passthease.motoragetraining.com/ProductSubCats.aspx?SubCatID=45',
};
const getRedirect = (url) => {
const redirect = redirects[url];
if (typeof redirect !== "undefined") {
return redirect;
} else {
return 'https://passthease.motoragetraining.com/';
}
}
// Here's a vanilla HTTP app to start,
// but feel free to replace it with Express, Koa, etc
const app = function(req, res) {
console.log(req.hostname);
if (req.hostname === 'motorage.com' || req.hostname === 'www.motorage.com') {
res.writeHead(301,{Location: `https://www.searchautoparts.com/motorage${req.url}`});
res.end();
} else if (req.hostname === 'member.utilityanalytics.com') {
res.writeHead(301,{Location: `https://connect.utilityanalytics.com${req.url}`});
res.end();
}
res.writeHead(301,{Location: getRedirect(req.url)});
res.end();
};
module.exports = app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment