Created
July 15, 2017 21:30
-
-
Save jgraup/cf372a7b3143f331cdfbef7cfb4a9b74 to your computer and use it in GitHub Desktop.
ngrok with local Vagrant WordPresss site
This file contains hidden or 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
# site.dev is the name of your hostname | |
HOST="site.dev"; | |
PORT=80; | |
IP="$(vagrant ssh -- -t 'ip address show eth1 | grep "inet " | sed -e "s/^.*inet //" -e "s/\/.*$//" | tr -d "\n" | tr -d "\r"; ')"; | |
echo -e "\nHOST:\t$HOST\nIP:\t$IP\nPORT:\t$PORT\n\tStarting ngrok "`date +%Y-%m-%d\ %H:%M:%S`... and opening http://127.0.0.1:4040/"\n"; | |
open http://127.0.0.1:4040; | |
ngrok http -host-header=$HOST $IP:$PORT |
This file contains hidden or 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
// Add to wp-config.php - change site.dev to your hostname | |
// Convert all site URLs to relative links in PHP output | |
ob_start( function( $string ) { | |
$host = "site.dev"; | |
return preg_replace( '/(http(?:s)?:\/\/)?(' . $host . ')(\/)?/mi', '/', $string ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment