我在前端建立了一个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吗?
我需要根据某些值的平均值对SQL表中的值进行排序.
我的'考试'表格如下:
+------------+------------+------+
| Exam | Student_ID |Points|
+------------+------------+-------
| Math | 3 | 20 |
|Accounts I | 23 | NULL |
|Statistics | 12 | 15 |
|Accounts II | 3 | 21 |
+------------+------------+------+
Run Code Online (Sandbox Code Playgroud)
这是我试过的查询:
SELECT Student_ID FROM Exams GROUP BY Student_ID ORDER BY avg(POINTS) desc
Run Code Online (Sandbox Code Playgroud)
我的目标是获得平均评分最高的学生的学生证,在这种情况下,3
我的方法是正确的,还是潜伏在那里?如何在Points列中处理NULL值?