Here's the URL (clearly works): http://beta.homehero.org/profile/1
On FB debugger it shows a 404 error and redirects back to beta.homehero.org/profile
https://developers.facebook.com/tools/debug/
I've got a totally basic .htaccess file, and permalinks looks like this:
/%category%/%postname%
This is really an author page, but I've renamed the base "profile".
Can someone help me get rid of this 404 error?
Agus Setiawan answers:
Try disabling W3TC or other cache plugin.
Then try saving the permalink settings again.
If you need to, disable plugins one by one to see if it's a plugin causing the error.
kaleazy comments:
I don't use any caching on this site, and all plugins are disabled.
Agus Setiawan comments:
ok, try add this on meta tag :
<meta property="og:url" content="http://beta.homehero.org" />
kaleazy comments:
I already have:
<meta property="og:url" content="http://beta.homehero.org/profile/1">
<link rel="canonical" href="http://beta.homehero.org/profile/1">
Agus Setiawan comments:
put this inside <HEAD> <meta content="text/html; charset=utf-8" http-equiv="content-type">
kaleazy comments:
Moved this meta tag into the header (below HTML)... still didn't fix.
Agus Setiawan comments:
no you're not. i see it still at on top. or it still in cache ?
kaleazy comments:
I disabled the cache, check now: http://beta.homehero.org/profile/1
Hariprasad Vijayan answers:
Hello,
Try to add "prefix" to your html tag
<html prefix="og: http://ogp.me/ns#">
You can find documentation in http://ogp.me/
Now your <html> tag is
<html lang='en' xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/">
Change it like
<html lang='en' xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" prefix="og: http://ogp.me/ns#">
Might help to solve this issue.
kaleazy comments:
Good idea, but still no luck. I assume the FB debugger will reflect changes right away?
Hariprasad Vijayan comments:
Are you getting same error when you try username instead of user id?
Hariprasad Vijayan comments:
Also change position of
<meta content="text/html; charset=utf-8" http-equiv="content-type">
it to <head>
kaleazy comments:
Moved this meta tag into the header (below HTML)... still didn't fix.
Hariprasad Vijayan comments:
can you replace change_author_permalinks_do() and user_rewrite_rules() functions with following code
add_action('init', 'change_author_permalinks_do');
function change_author_permalinks_do() {
global $wp_rewrite;
$author_slug = 'profile';
$wp_rewrite->author_base = $author_slug;
$wp_rewrite->flush_rules( false );
}
add_filter('generate_rewrite_rules','user_rewrite_rules');
function user_rewrite_rules( $wp_rewrite ) {
$newrules = array();
$new_rules['profile/(\d*)$'] = 'index.php?author=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
$wp_rewrite->flush_rules( false );
}
kaleazy comments:
When I add the flush_rules I get:
PHP Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 523800 bytes) in /Users/kaleazy/MAMP/HomeHero/wp-includes/option.php on line 1350
And the page won't even load.
Hariprasad Vijayan comments:
oh. okay. Try following code in functions.php. Then deactivate and reactivate theme. Just experiment. not 100% sure it solve the issue.
/* Flush rewrite rules for custom post types. */
add_action( 'after_switch_theme', 'bt_flush_rewrite_rules' );
/* Flush your rewrite rules */
function bt_flush_rewrite_rules() {
flush_rewrite_rules();
}
Hariprasad Vijayan comments:
Remove changes that made in change_author_permalinks_do() and user_rewrite_rules() it won't work. Just try last code.
kaleazy comments:
Ok, kept old code as it is, added these two lines after it, changed themes and back again. FB still giving 404 :(
Dbranes answers:
I think this is wrong:
<!DOCTYPE html>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<html lang='en' xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/">
i.e. don't add meta before html tag, put it inside the header tag instead.
This might give Facebook problems parsing your site.
Dbranes comments:
ps: it looks like you are using the WPEngine cache mechanism.
Your page response header gives the following information (10 min cache):
Server: WP Engine/6.0.2
Date: Thu, 27 Feb 2014 14:04:20 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
X-Pingback: http://beta.homehero.org/xmlrpc.php
X-Cacheable: SHORT
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=600, must-revalidate
X-Cache: HIT: 3
X-Cache-Group: normal
X-Type: default
kaleazy comments:
Yes, we use WPEngine. I forgot they are caching this. Could this be related to the 404?
Dbranes comments:
Check your logs, if you can see the FB debugger hitting the page.
Dbranes comments:
Your page is returning
HTTP/1.1 200 OK
in the header, so the status looks ok.
But can you see it in your logs, if the FB debugger is receiving another status?
Dbranes comments:
by the way, your HTML structure is somewhat strange, you got many DIVs inside the head tag.
<head>
...
</div>
<div id="jobsModal" class="modal fade hide"></div>
<div id="spinner" class="restricted"><span id="spinner-box"><span id="spinner-gif"></span></span></div>
<div id="alert" class="alert"></div>
</head>
You should move them all, inside the body tag.
kaleazy comments:
Just moved these outside the <head>
John Cotton answers:
Is that a custom url?
Are you rewriting it in .htaccess or some other way?
If WP doesn't know about it it will return a 404 header even if it can actually produce HTML for output.
You need to add to the rewrite rules so that WP knows it has content to output.
kaleazy comments:
These are actually just author pages, but I'm using "profile" instead of "author" and ID's instead of usernames. Same problem even when using author and usernames (standard wordpress).
John Cotton comments:
How did you change the slug? In code or with a plugin?
And are you sure FB isn't looking at a cached version of the page (cached at their end, not yours)?
kaleazy comments:
No I'm not sure, but I tried with a completely different URL and same problem:
http://betahomehero.wpengine.com/profile/1
The slug is normal author pages:
http://beta.homehero.org/author/username
But with added three functions to change the base name and username to ID:
http://beta.homehero.org/profile/ID
This is what I added...
add_action('init', 'change_author_permalinks_do');
function change_author_permalinks_do() {
global $wp_rewrite;
$author_slug = 'author';
$wp_rewrite->author_base = $author_slug;
}
add_filter('query_vars', 'users_query_vars');
function users_query_vars($vars) {
// add lid to the valid list of variables
$new_vars = array('profile');
$vars = $new_vars + $vars;
return $vars;
}
add_filter('generate_rewrite_rules','user_rewrite_rules');
function user_rewrite_rules( $wp_rewrite ) {
$newrules = array();
$new_rules['profile/(\d*)$'] = 'index.php?author=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
John Cotton comments:
Your code looks OK.
Just to rule out that it's not WordPress sending the 404, you could quickly edit the core code in wp-includes/class-wp.php around line 585 (// Guess it's time to 404.) - line varies with version that you have.
Stick a wp_die('404') in there and visit the troublesome page again.
If you don't get the die (and remember that WPEngine might be caching so clear out) then at least you know it's not that.
I have seen WP return 404's in some odd situations over the years and servers like FB pay a lot more attention to headers than others might.
kaleazy comments:
Ok here's what I added to class-wp.php:
// Guess it's time to 404.
$wp_query->set_404();
//status_header( 404 );
wp_die('404');
nocache_headers();
Doesn't seem to kill the page.
John Cotton comments:
<blockquote>Doesn't seem to kill the page.</blockquote>
OK - it was worth checking.
<blockquote>66.220.152.117 beta.homehero.org - [27/Feb/2014:20:39:32 +0000] "GET /profile HTTP/1.1" 404 57 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"</blockquote>
There's your problem - FB is looking at /profile not /profile/id
You don't have a rewrite rule for /profile
John Cotton comments:
... and http://beta.homehero.org/profile/ gives you the 404 die!
kaleazy comments:
Ok yea that makes sense. How can I get it to stay on /profile/id and not forward to /profile?
John Cotton comments:
<blockquote>Ok yea that makes sense. How can I get it to stay on /profile/id and not forward to /profile?</blockquote>
I think your problem is related to your use of a custom namespace for og:type which you don't declare.
Try making it something standard like profile first and see if that fixes it.
The custom namespace is written like this:
<head prefix="my_namespace: http://example.com/ns#">
<meta property="og:type" content="my_namespace:my_type" />
See [[LINK href="http://ogp.me/"]]http://ogp.me/[[/LINK]] for more.
Abdelhadi Touil answers:
Hi.
Have you tried to debug the page using the default author url without base change?
kaleazy comments:
Yes, same problem with this: http://beta.homehero.org/author/username
Arnav Joy answers:
can you install this plugin and check what the problem may be
http://wordpress.org/plugins/debug-this
kaleazy comments:
I can see when FB hits my site:
66.220.152.117 beta.homehero.org - [27/Feb/2014:20:39:32 +0000] "GET /profile HTTP/1.1" 404 57 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"