我正在配置我的apache服务器来处理prerender的中间件,除了根路径之外,它实际上运行良好。
当我尝试抓取 www.example.com?_escaped_fragment _ 时,会返回 www.example.com / ,但未找到预渲染中间件。
像www.example.com/foo?_escaped_fragment_这样的其他网页可以正常使用。
这是我的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>