dousi6303 2013-08-02 13:12
浏览 16
已采纳

在HTTP 200中呈现HTML而不是404 - 在URL中重音

I have a problem regarding social buttons: facebook like and google plus that don't work. It's a special case because the URL contains accents and it conflicts with the encoded form. Anyways, now I try to handle both requests with PHP. It wouldn't be neccessary because browsers are intelligent enough to redirect, but these social apps test the URL for errors. If the URL to like or plus one seems to be invalid (responds 404), you cannot like or plus anything.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 /index.php

This is the relevant part of .htaccess for you to get a closer image of the URL structure.

The problem is, the URL looks like:

http://business1.hu/makrogazdaság/a-snowden-ügy-nyertesei

The encoded form, http://business1.hu/makrogazdas%C3%A1g/a-snowden-%C3%BCgy-nyertesei if typed into a browser address field, the browser will say: Okay, I know this is a URL endoded form, I'd better decode it and show the actual page. But this url itself returns no content, a 404 PAGE. And I couldn't solve this in PHP.

So the thing I type in after http://business1.hu/ seems to return a 404 error and SHOWS CONTENT at the same time.

I guess /makrogazdaság returns 200, but /makrogazdas%C3%A1g returns 404. They are meant to show the same exact page. But Facebook cannot handle /makrogazdaság.

Please help.

  • 写回答

1条回答 默认 最新

  • dongqiao2077 2013-08-02 14:14
    关注

    You won't believe how simple it was.

    header("Status: 200 OK"); solved everything.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?