[wp-trac] Re: [WordPress Trac] #6298: Canonical redirect broken on static front page

WordPress Trac wp-trac at lists.automattic.com
Wed Mar 19 10:39:48 GMT 2008


#6298: Canonical redirect broken on static front page
-------------------------------+--------------------------------------------
 Reporter:  Denis-de-Bernardy  |        Owner:  anonymous
     Type:  defect             |       Status:  new      
 Priority:  normal             |    Milestone:  2.5      
Component:  Optimization       |      Version:  2.5      
 Severity:  major              |   Resolution:           
 Keywords:                     |  
-------------------------------+--------------------------------------------
Comment (by Denis-de-Bernardy):

 Fix:

 {{{

                 if ( is_front_page() )
                 {
                         $home_url = get_option('home');
                         $home_path = parse_url($home_url);
                         $home_path = $home_path['path'];

                         if ( rtrim($_SERVER['REQUEST_URI'], '/') !=
 rtrim($home_path, '/') )
                         {
                                 header('HTTP/1.1 301 Moved Permanently');
                                 header('Status: 301 Moved Permanently');

                                 #var_dump(rtrim($_SERVER['REQUEST_URI'],
 '/'), rtrim($home_path, '/'));

                                 wp_redirect($home_url);
                                 die;
                         }
                 }

 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6298#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list