Skip to content

Instantly share code, notes, and snippets.

@hyukishi
Created February 6, 2019 17:20
Show Gist options
  • Select an option

  • Save hyukishi/5ced7f90d72662ea99a87e809799d74d to your computer and use it in GitHub Desktop.

Select an option

Save hyukishi/5ced7f90d72662ea99a87e809799d74d to your computer and use it in GitHub Desktop.
Add a 301 redirect to point to the https (secure) url
#!/bin/bash
# Created by Jeffery Grantham 01/07/2019
# Purpose: Easily implement 301 redirects into website conf files
# Written for use with apache only
# Usage: 301.sh [.conf file]
FILE=$1
cd /etc/apache2/sites-available/
sed "/CustomLog/a\ \tRedirect 301 / https://$FILE.com/" $FILE.conf> tempfile && mv tempfile $FILE.conf
cat $FILE.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment