LoginSignup
6
6

More than 5 years have passed since last update.

URLの存在確認をする

Posted at

Apacheのrewriteの設定を編集する機会があったので、念のため現在のリダイレクト先が存在しているかチェックした。
存在していなかったらそのURLを表示する。

チェックするURLを記載するファイル

urls.txt
/terms/privacy.html
/terms/terms.html
.
.

チェックスクリプト

checkurl.sh
#!/bin/bash

for uri in `cat -`
do
  result=`curl -LI http://example.com${uri} -w '%{http_code}\n' -s -o /dev/null`
  if [ 404 = "${result}" ]; then
    echo "${uri}" 
  fi
done

実行

cat urls.txt | sh checkurl.sh
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6