escaped_fragment 请求不解析 php?
所以最近我按照 Google 的 AJAX 抓取方法重建了我的网站。
一切工作正常, ?_escaped_fragment_=
请求工作正常,但我注意到页面上的任何 php 都没有被解析,并被注释掉,如下所示:
有谁知道为什么会发生这种情况?这是我索引中的一些 PHP:
$fragment = $_GET['_escaped_fragment_'];
$file = '' . (isset($fragment) && $fragment != '' && $fragment != '/' ? preg_replace('/\//', '', $fragment) : 'home') . '.html';
$re = '/(^<[^>]*>)|(\n|\r\n|\t|\s{2,4})*/';
$handle = fopen($file, 'r');
if ($handle != false) {
$content = preg_replace($re, '', fread($handle, filesize($file)));
fclose($handle);
} else {
$content = 'Page not found!';
header(php_sapi_name() == 'cgi' ? 'Status: 404' : 'HTTP/1.1 404');
}
我注意到其中有一个正则表达式。也许这有什么关系?我无法完全理解这里发生的事情,我不是专家。 如果这会一直这样的话,我不想恢复我的网站..
请帮我一把
so recently ive rebuilt my site following Google's AJAX Crawling methods.
Everything works fine and an ?_escaped_fragment_=
request works fine but i've noticed any php on the page is not parsed and is commented out like so: <!--?php echo $myvar ?-->
Does anyone know why this may be happening?? here is some PHP from my index:
$fragment = $_GET['_escaped_fragment_'];
$file = '' . (isset($fragment) && $fragment != '' && $fragment != '/' ? preg_replace('/\//', '', $fragment) : 'home') . '.html';
$re = '/(^<[^>]*>)|(\n|\r\n|\t|\s{2,4})*/';
$handle = fopen($file, 'r');
if ($handle != false) {
$content = preg_replace($re, '', fread($handle, filesize($file)));
fclose($handle);
} else {
$content = 'Page not found!';
header(php_sapi_name() == 'cgi' ? 'Status: 404' : 'HTTP/1.1 404');
}
I noticed a regexp in there. Maybe that has something to do with it? I cant fully understand whats going on here, im no expert.
Dont exactly want to put my site back up if this is gonna stay like this..
Please lend me a hand here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是通过创建 PHP if else 语句解决的。
this was solved by creating a PHP if else statement.