apache - 为主页提供静态 html,否则提供给 index.php
问题描述
我有一个非常标准的重写规则,可以将所有内容推送到我的 CMS 处理的索引中。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
我想将我的主页和几个基石博客作为静态 html 来提供,以提高加载速度。/path/to/some.html
当请求 root 时,我如何告诉 Apache2 服务?
我试过了
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^/$ /path/to/some.html
RewriteCond %{REQUEST_URI} "^/some/important/path$"
RewriteRule ^/$ /path/to/some/other.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
但这一切仍然通过索引提供服务并由 CMS 处理。我究竟做错了什么?
解决方案
看起来这是在 .htaccess 中,所以每次更改后,处理将使用新路径重新开始。当规则真的知道它想要成为最终规则时,添加了 [END] 标志以帮助缩短这种循环。
相比之下,现有的 [L] 标志仅停止当前轮的处理。
推荐阅读
- python - 在 Django 中使用验证器无法正常工作
- google-cloud-storage - 在 Airflow 任务中从 Google Cloud Storage 导入 JSON
- javascript - 创建一个检查对象的函数
- mysql - 在 MySQL 中是否可以找到最小值/最大值但首先删除异常值?
- python - Discord.py - 允许特定频道中的命令
- android - 如何克服 IONIC Vue 3 android 构建中的 CORS 错误?
- json - 如何使用 id/codarea 作为标识符将一个 json 中的特征信息添加到 geoJson 中?
- python - 使用基于计数的迭代结构的初学者 Python 程序
- java - 给你两个二叉搜索树的根节点。确定两棵树是否存储相同的数字
- kotlin - 如何实现消息中重复的 gRPC/Proto 端点(即请求和响应中的嵌套类型)