Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added directory scripts and fixed bugs
- Loading branch information
Chris More
committed
Mar 22, 2012
1 parent
0993ade
commit b283469
Showing
5 changed files
with
32 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,20 @@ | ||
#!/bin/bash | ||
|
||
pro="http" | ||
address=$1 | ||
address="http://$1" | ||
response="301" | ||
|
||
# Find redirected address | ||
count=0 | ||
while [ $response == "301" ] || [ $response == "302" ] | ||
do | ||
address=$(curl -k --write-out %{url_effective} --silent --output /dev/null -L $address) | ||
response=$(curl -k --write-out %{http_code} --silent --output /dev/null $address) | ||
|
||
# Check to see if a website is just redirecting from http to https | ||
website_redirected=$(curl --write-out %{url_effective} --silent --output /dev/null -L $pro://$address) | ||
if [ "https://$address/" == "$website_redirected" ]; then | ||
pro="https" | ||
# Check redirector again incase it redirects a second time (localization) | ||
website_redirected2=$(curl --write-out %{url_effective} --silent --output /dev/null -L $website_redirected) | ||
if [ "$website_redirected2" == "" ]; then | ||
#If the website did not redirect again after switching to https, then set address_final to current address. | ||
address_final=$website_redirected | ||
else | ||
#If the website redirected a second time, set the address_final variable to the second redirected address. | ||
address_final=$website_redirected2 | ||
fi | ||
else | ||
# website stayed http | ||
if [[ "$website_redirected" != "" ]]; then | ||
# website redirected, but stayed on the same domain. Probably l10n redirection. | ||
website_redirected2=$(curl --write-out %{url_effective} --silent --output /dev/null -L $website_redirected) | ||
|
||
if [ "$website_redirected2" == "" ]; then | ||
# website did not redirect to a subdirectory. | ||
address_final=$website_redirected | ||
else | ||
#If the website redirected a second time, set the address_final variable to the second redirected address. | ||
address_final=$website_redirected2 | ||
fi | ||
|
||
else | ||
address_final="$pro://$address" | ||
fi | ||
(( count++ )) | ||
|
||
if [ $count == 10 ]; then | ||
break | ||
fi | ||
|
||
echo $address_final | ||
done | ||
|
||
echo $address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters