.htaccess htaccess重写url导致og元标记出错
我的教会网站有og元标签,用于描述和图像以及所有这些。他们都工作得很好。 最近,他们要求我从url中删除.php扩展名,所以我使用htaccess实现了这一点。所有的重写似乎都能很好地使用它.htaccess htaccess重写url导致og元标记出错,.htaccess,meta-tags,.htaccess,Meta Tags,我的教会网站有og元标签,用于描述和图像以及所有这些。他们都工作得很好。 最近,他们要求我从url中删除.php扩展名,所以我使用htaccess实现了这一点。所有的重写似乎都能很好地使用它 # Turn mod_rewrite on RewriteEngine On # Make all requests have the www. in them RewriteCond %{HTTP_HOST} ^ourchurch\.com RewriteRule ^(.*)$ http://www.o
# Turn mod_rewrite on
RewriteEngine On
# Make all requests have the www. in them
RewriteCond %{HTTP_HOST} ^ourchurch\.com
RewriteRule ^(.*)$ http://www.ourchurch.com/$1 [R=permanent,L]
## don't touch /my_admin_controls URIs
RewriteRule ^my_admin_controls/ - [L,NC]
## don't touch /ourScheduler URIs
RewriteRule ^ourScheduler/ - [L,NC]
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_FILENAME}.php [L]
现在,由于某些原因,facebook og标签无法正常工作。
我查看了调试器,它说有重定向错误
有人知道我哪里出错了吗
…编辑。。。
og的样本
<head>
<meta charset="UTF-8">
<meta property="og:image" content="http://www.ourchurch.com/images/fblogo.jpg"/>
<meta property="og:title" content="Fall Retreat"/>
<meta property="og:url" content="http://www.ourchurch.com/fall_retreat.php"/>
<meta property="og:site_name" content="Our church .....etc etc"/>
<meta property="og:description" content="Come for fellowship...etc etc."/>
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen" />
<title>Retreat Registration</title>
</head>
务虚会注册
我认为这是因为您在.htaccess
中使用重定向来删除扩展名,即R标志,请尝试以下代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
此外,从元标记代码中,您有:
<meta property="og:url" content="http://www.ourchurch.com/fall_retreat.php"/>
应该是:
<meta property="og:url" content="http://www.ourchurch.com/fall_retreat"/>
因为您已经进行了重定向以删除.php
,所以Facebook遭受重定向循环,无法访问页面
参考资料:
标记之间。这很有意义。。我将尝试从og中删除它,看看是否需要进一步编辑我的htaccessYou删除og标记中的.php是正确的。非常感谢。为了进一步了解,我是否应该开始从所有内部链接中删除.php以减少htaccess的重定向数量?还是让a标签保持原样?你说的内部链接是什么意思?如果你指的是网站页面中链接到其他页面的链接,那么最好也这样做,除了更改og url
。是的,我只是在导航区域中引用了指向其他页面的链接。