say i have a file named redirections.txt that looks like this:
www: http://www.example.com/hub/
icloud: http://www.example.com/icloud/
dev: http://www.example.com/development/latest/projects.php
how would i go about processing that text document as domain-prefix: redirect-url
? (or "if $_SERVER['HTTP_HOST'] equals domain-prefix.example.com, goto redirect-url")
currently i have:
$file = file('redirections.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($file as $line => $cont){
preg_match('/(*.?): http:\/\/www.example.com\/(*.?)\//', $cont, $matches);
print_r($matches); // Debug. Was trying to see if it worked.
}