Apache 根路径don'的预渲染重定向;行不通

Apache 根路径don'的预渲染重定向;行不通,apache,prerender,Apache,Prerender,我正在配置我的apache服务器来处理prerender的中间件,除了根路径之外,它实际上工作得很好 当我尝试爬网www.example.com?\u转义\u片段时,它返回www.example.com/,但未到达预渲染中间件 其他页面,如www.example.com/foo?\u expaired\u fragment\u工作正常 以下是我的apache配置: <VirtualHost *:443> ServerAdmin *** ServerName examp

我正在配置我的apache服务器来处理prerender的中间件,除了根路径之外,它实际上工作得很好

当我尝试爬网www.example.com?\u转义\u片段时,它返回www.example.com/,但未到达预渲染中间件

其他页面,如www.example.com/foo?\u expaired\u fragment\u工作正常

以下是我的apache配置:

<VirtualHost *:443>
    ServerAdmin ***
    ServerName example.com
            ServerAlias www.example.com

    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

    DocumentRoot /var/www/example/current/web

    LogLevel warn

    <Directory /var/www/example/current/web>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    DirectoryIndex app.php

    ErrorDocument 503 /maintenance.html

    <Location />
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteRule .? - [L]

        # Catch all request if crawler and redirect to Prerender server
        RewriteCond %{HTTP_USER_AGENT} Google(.*)|Facebot|googlebot|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
        RewriteCond %{QUERY_STRING} _escaped_fragment_
        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))(app\.php)?(.*) http://prerender.example/https://%{HTTP_HOST}%{REQUEST_URI} [P,L]

        # Catch all request if we are on maintenance
        RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
        RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
        RewriteCond %{SCRIPT_FILENAME} !maintenance.html
        RewriteRule ^.*$  -  [redirect=503,last]

        # Rewrite all other queries to the front controller.
        RewriteRule .? %{ENV:BASE}/app.php [L]

    </IfModule>

    <IfModule !mod_rewrite.c>
        <IfModule mod_alias.c>
            RedirectMatch 302 ^/$ /app.php/
        </IfModule>
    </IfModule>
    </Location>

</VirtualHost>

服务器管理员***
ServerName example.com
ServerAlias www.example.com
setenif Authorization“(*)”HTTP_Authorization=$1
DocumentRoot/var/www/example/current/web
日志级别警告
选项-索引+FollowSymLinks+多视图
不允许超限
命令允许,拒绝
通融
DirectoryIndex app.php
错误文档503/maintenance.html
重新启动发动机
重写基/
RewriteCond%{REQUEST_FILENAME}-f
重写规则[L]
#捕获爬虫的所有请求并重定向到Prerender服务器
RewriteCond%{HTTP|u USER|u AGENT}Google(.*)Facebot | googlebot | baiduspider | facebook外部点击| twitterbot | rogerbot | linkedinbot |嵌入| quora\link\preview | showyoubot outbrain | pinterest | slackbot vkShare | W3C|验证程序[NC,或]
重写cond%{QUERY\u STRING}\u转义\u片段_
(10.js 124?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????|\.mov\.psd\.ai\.xls\.mp4\.m4a\.swf\.dat\.dmg\.iso\.flv\.m4v\.torrent\.ttf\.woff()(app\.php);()http://prerender.example/https://%{HTTP_HOST}%{REQUEST_URI}[P,L]
#如果我们正在进行维护,则捕获所有请求
重写条件%{REQUEST\u URI}!\。(css | gif | jpg | png)$
RewriteCond%{DOCUMENT_ROOT}/maintenance.html-f
重写cond%{SCRIPT_FILENAME}!maintenance.html
重写规则^.*$-[redirect=503,last]
#将所有其他查询重写到前端控制器。
重写规则.?%{ENV:BASE}/app.php[L]
重定向匹配302^/$/app.php/

如果将预渲染重写规则移到文件的第一个重写规则之上,是否有效?请求您的主页时,您的app.php可能会在那里提供。谢谢@Prerender.io,我将Prerender规则移到了第一个位置,它可以工作!如果将Prerender重写规则移到文件的第一个重写规则之上,是否有效?请求您的主页时,您的app.php可能会在那里提供。谢谢@Prerender.io,我将Prerender规则移到了第一个位置,它可以工作!