如何更正代理搜索引擎抓取请求的htaccess?

Naw*_*gle 7 regex apache .htaccess reactjs

我在前端建立了一个React的网站,而后端是WordPress.为了让搜索引擎爬虫能够看到我的网站,我已经在服务器端设置了预呈现,并且我正在尝试设置htaccess来代理来自搜索引擎的请求,以便为它们提供预渲染页面.

为了进行测试,我使用的是Google网站管理员中的"Google抓取方式"工具.

这是我的尝试:

<IfModule mod_rewrite.c>
    RewriteEngine On
    <IfModule mod_proxy_http.c>
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR]
    RewriteCond %{QUERY_STRING} _escaped_fragment_
    # Proxy the request ... works for inner pages only
    RewriteRule ^(?!.*?)$ http://example.com:3000/https://example.com/$1 [P,L]

    </IfModule>
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Run Code Online (Sandbox Code Playgroud)

我的问题是该指令不适用于我的主页,仅适用于内页(http://example.com/inner-page/):

RewriteRule ^(?!.*?)$ http://example.com:3000/https://example.com/$1 [P,L]
Run Code Online (Sandbox Code Playgroud)

当我将此行更改为以下行时,主页请求确实正确代理,但内部页面停止工作.

RewriteRule ^(index\.php)?(.*) http://example.com:3000/https://example.com/$1 [P,L]
Run Code Online (Sandbox Code Playgroud)

你能帮我修复重写规则,以便我的主页也能正确代理googlebot吗?

Cro*_*ses 1

将其更改RewriteRule为:

RewriteRule ^(.*)/?$ http://example.com:3000/https://example.com/$1 [P,L]
Run Code Online (Sandbox Code Playgroud)