Opened 18 years ago
Closed 16 years ago
#6298 closed defect (bug) (duplicate)
Canonical redirect broken on static front page
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | 2.5 |
| Component: | Optimization | Keywords: | |
| Focuses: | 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 (7)
Note: See
TracTickets for help on using
tickets.
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; } }