• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.3 Links posted to Facebook are malformed - "The requested page could not be found"

sforum

Active member
#1
I don't believe this is a bug with xenForo per sé, hence why I have posted in here asking for support, rather than submitting a Bug Report.

I have just shared a link to a thread on my Facebook page. If you click this from a computer, it works fine, and takes you to the thread in question. If you click it from the Facebook app on iPhone, however, it results in:

facebook_link_error_2014-09-05-14.14.jpg

I have copy & pasted the link that the Facebook app is actually sending people to, and it seems to have parsed incorrectly.

It should be:

Code:
http://www.mydomain.com/index.php?threads/threadname.14503/
But the Facebook app seems to be sending people to:

Code:
http://www.mydomain.com/index.php?threads%252Fthreadname.14503%252F
I've tried reducing this to just:

Code:
http://www.mydomain.com/index.php?threads/14503/
Thinking that this would eliminate a lot of the malformed control codes and thus solve the problem, but alas no joy.

A friend has tested it on his HTC One M8 and it works fine for him, so it seems to just be iOS (tested on iOS 7 on iPhone 5 and iPad 3).

Any suggestions? I appreciate that this is more of a Facebook/Apple bug than xenForo, but I thought some of you resourceful types might have a way round the issue. :)

All I can think of is using a URL shortening service and post the short URL, but I'm not sure if this would even work (e.g. would it present the OG logo, etc.).

Any help appreciated; so many users browse on their phones these days, I'd really like to get this sorted!

Thanks.
 

Brogan

XenForo moderator
Staff member
#2
A forward slash / is actually URL double-encoded as %252F, which is what you are seeing.
It's only happening after the query string though.

It's more than likely a FB/iOS issue as that should be URL decoded.
 

Mike

XenForo developer
Staff member
#3
If it is only happening in the query string, then enabling friendly URLs may help. But yeah, almost certainly a FB issue.
 

sforum

Active member
#4
If it is only happening in the query string, then enabling friendly URLs may help. But yeah, almost certainly a FB issue.
Hmm. It only seems to be encoding the forward slashes after the ampersand, so I dare say you're right. I've always been scared by enabling friendly URLs, though, as it says you need a specific .htaccess, and I'm worried I'll bugger it up!

Ah well. Perhaps a URL shortener would be my only way round it for the time being.
 

sforum

Active member
#6
Instructions for Friendly URLs are here: https://xenforo.com/help/friendly-urls/

In most cases all you need to do is rename the htaccess.txt file to .htaccess
Ah, perhaps it's not as scary as I thought!

My current .htaccess is:

PHP:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

ErrorDocument 404 http://www.mydomain.com/index.php?pages/404page/
As I'm sure you can figure out, this is so that people are pointed to a custom 404 page, in addition to making sure everyone is redirected to the www. prefixed site.

Would I still need to make any changes before clicking that magical "Enable Full Friendly URLs", or would the above suffice?

Thanks.
 

Brogan

XenForo moderator
Staff member
#7
You would need to include the relevant lines from the htaccess.txt file.

Code:
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]