This is an automated script to test 301 redirects in bulk. There are both pure node and jasmine-node implementations. This script only accesses the original URL and checks that the location header returns the expected result. It DOES NOT check the page redirected to. It can be easily modified to check for other response codes.
- Install node
- Clone this repository
- npm install
- Create a redirects.txt file as listed below.
- Edit redirectTest.js to specify the base URL and enable/disable reporting comments.
- node redirectTest.js
The script will check each line in redirects.txt, requesting the first page, checking that the response code is 301, and checking that the location header matches the second parameter. It prints 'DONE' when all checks have been run, but any errors on those last few requests may come back after that point.
- Install node
- Clone this repository
- npm install jasmine-node -g
- Create a redirects.txt file as listed below.
- Edit redirectsSpec.js to specufy the base URL
- jasmine-node redirectSpec.js
This script performs the same checks as the previous, but it uses jasmine-node's structure for reporting. It can also be easily extended with jasmine-node's matchers
This file should have the pairs to be tested, one pair per line, in the following format.
/path/to/old/resource/1 http://www.example.com/new/path/to/resource/1
/path/to/old/resource/2 http://www.example.com/new/path/to/resource/2
/path/to/old/resource/3 http://www.example.com/new/path/to/resource/3