Make WordPress Core

Ticket #21143: sunrise.php

File sunrise.php, 694 bytes (added by jamescollins, 12 years ago)

Example wp-content/sunrise.php file that uses the new 'no_blog_redirect' hook

Line 
1<?php
2
3function my_no_blog_redirect( $domain, $blogname, $current_site, $current_blog, $path ) {
4
5        // If we are here then a valid blog hasn't been found for this request
6
7        // Perform our own checking to see if   we need to do a 301 redirect from the requested domain to another domain
8        $domain_redirect = domain_redirect_location_lookup( $domain, $blogname, $current_site, $current_blog, $path );
9
10        if ($domain_redirect) {
11                header( "HTTP/1.1 301 Moved Permanently" );
12                header( "Location: http://{$domain_redirect}{$_SERVER['REQUEST_URI']}" );
13                exit;
14        }
15        // Otherwise WordPress will fall back to using the NOBLOGREDIRECT constant
16}
17add_action('no_blog_redirect', 'my_no_blog_redirect', 10, 5 );