php - 如何使用 .htaccess 切换内容以在维护消息下显示
问题描述
我想/blog
在我的应用程序上有一个目录,以便在那里安装一个 WordPress 实例。目前/blog
确实将我带到那里,但我确实想知道并拥有控制权,而不是如何从目录中读取routes.php
.
它可能有很多用例,因为blog
目录正在维护或关闭,在这种情况下,只需进行简单的更改,它就会/blog
从routes.php
.
我不是'.htaccess'文件的专家,但我们可以这样做吗?
解决方案
如果您的 CI 应用程序使用默认路由配置,那么 /blog 将使 CI 尝试加载博客控制器和索引操作,如果它找不到它们。你会得到 404 page not found 错误。尝试在您的 Web 服务器配置中配置 /blog。添加 /blog 块,然后在那里应用 wordpress 服务器配置。确保请求将在 /location 块之前找到 /blog 位置块。在 nginx 中:
location /blog {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
# then your ci / location
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
推荐阅读
- kubernetes - 如何每 2 分钟运行一次 cron,但从特定小时的第 5 分钟开始?
- ansible - 如何在 Ansible Tower 中执行语法检查?
- sql - How to filter integer with specific numbers in sql
- tensorflow - 如何强制自动编码器中的瓶颈产生二进制值?
- node.js - 插入、更新和删除与 insertOne、updateOne 和 deleteOne(或 -Many)
- php - 如何在 codeIgniter 中使用迁移?
- reactjs - 如何使用reactjs在grpc调用中传递数组
- mysql - Mysql 查询到 ElasticSearch
- spring - WebFlux.fn 根本不路由
- firebase - 将函数模拟器与实时数据库一起使用