Ticket #6298 (new defect)

Opened 8 months ago

Last modified 7 months ago

Canonical redirect broken on static front page

Reported by: Denis-de-Bernardy Assigned to: markjaquith
Priority: normal Milestone: 2.9
Component: Optimization Version: 2.5
Severity: major Keywords:
Cc:

Description

Create a static page, 'Test', publish and browse the page.

In a separate window, browse settings / reading, set this page as the static front page.

Return to the initial window, refresh.

Behavior produced: WP displays the page as it normally would.

Expected behavior: WP redirects to get_option('home');

Change History

03/19/08 10:39:48 changed 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;
			}
		}

03/19/08 18:57:11 changed by lloydbudd

  • owner changed from anonymous to markjaquith.

04/16/08 23:14:20 changed by Denis-de-Bernardy

the above code has a tiny bug: the is_paged() case also needs to be processed.

D.