apache - 如何将以下简单的 Nginx 重写条件和规则转换为 Apache .htaccess
问题描述
我想将以下 Ngnix 重写规则和条件转换为 Apache .htaccess,但我无法成功。
location /app/ {
if (!-e $request_filename) {
rewrite ^ /app/index.html break;
}
}
location ~ /app/account/(.*?)$ {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /app/pay/(.*?)$ {
try_files $uri $uri/ /index.php?$query_string;
}
解决方案
您能否仅根据您显示的代码尝试以下操作。此外,我不是 nginx 专家,但我在这里尽了最大努力 :) 请确保在测试 URL 之前清除浏览器缓存。
显然,如果您可以为我们提供 URL 示例,其中包含您想要重写/重定向的从哪个 url 到哪个 url 的逻辑,那么它会更容易更好地理解它,并且对测试也有帮助。
RewriteEngine ON
##First rule here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /app/index.html [L]
##Second rule here....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^app/account/(.*)/?$ index.php?$1 [L]
##Third rule here....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^app/pay/(.*)/?$ index.php?$1 [L]
推荐阅读
- python - 将numpy数组转换为给定格式的字符串
- javascript - 如何读取复选框和单选按钮的值
- node.js - 为 aws lambda 实现日志记录级别
- windows - 如何使用 ascii 在 powershell 中运行 base64 代码?
- terraform - 在terraform中增加标签索引
- r - 如何去除频率图的零频率并固定时间?
- jquery - 有没有办法在设定的时间过后刷新剑道窗口的内容?
- python - 如何通过 pd.read_sql 传递多个参数,一个单数,另一个以列表格式传递?
- python - 如何使用消息按钮或链接在 Slack 上发送临时应用程序下载链接 itms-service
- sql - 如何从 SQL 中的单列数据(日期时间格式的登录)中获取每天每小时的平均登录次数?