.htaccess 在htaccess文件中安装预呈现标记

ulydmbyx  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(120)

我已经搜索了几天,但仍然有一个问题,与htaccess文件安装prerender.io令牌。我得到了这个消息后,保存和测试各种htaccess格式:
我们尚未看到使用您的Prerender令牌的请求。单击此处查看如何在中间件中安装令牌。
实际上所有的页面都被缓存了!我的项目是ReactjsCodeigntier,共享主机在Apache上。
我有一个htaccess文件,如下所示:

# this section for forcing https and www
RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteRule (.*) https://www.mokaab.com/$1 [R,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#  this is the code which provided on Prerender website
<IfModule mod_headers.c>
    RequestHeader set X-Prerender-Token "TOKEN"
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    <IfModule mod_proxy_http.c>
        RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
        RewriteCond %{QUERY_STRING} _escaped_fragment_
        
        # Only proxy the request to Prerender if it's a request for HTML
        RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/https://www.mokaab.com/$2 [P,L]
    </IfModule>
</IfModule>

# this is for avoiding 404 page when refreshing page on React apps
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

此外,我已经改变了他们的位置,但仍然有一个问题!然后我把下面的 meta标记在部分:
<meta name="fragment" content="!">
我认为问题出在htaccess上。

czfnxgou

czfnxgou1#

.htaccess文件是正确的!问题出在主机的配置上!必须在每种类型的主机上启用这些配置:

mod_headers.c
mod_rewrite.c
mod_proxy_http.c

显然,前两个选项在正常主机上启用,但最后一个选项需要SSH,这是不可用的!

相关问题