apache - 在子文件夹中重写 Htaccess 中的 Base
问题描述
我网站上的所有路径都是相对 URL,并以 / 开头,这在生产中很好,但我将它带回开发并将其放在 /app 的路径下我尝试使用 RewriteBase 设置但它没有改变任何网站上的路径。我错过了什么吗?
RewriteEngine On
RewriteBase /app/
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/(.+)/(.+)$ $1.php?type=$2&loan-type=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/(.+)$ $1.php?type=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [L,QSA]
将所有根目录重定向到 /apps 的根 htaccess 设置,而不仅仅是 /apps 的子目录。
RewriteEngine On
RewriteRule ^(?!app/)(.+)$ /app/$1 [L,NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
解决方案
您可以在站点根目录 .htaccess 中使用此规则:
RewriteEngine On
RewriteRule ^(?!app/)(.+)$ app/$1 [L,NC]
推荐阅读
- django - Django-Static 文件,如何关闭 yourdoman/static 文件索引
- android - 如何在 Recyclerview 的单击上打开“详细信息”片段
- python - Python Tkinter改变框架背景颜色看似没有效果
- java - 我怎样才能有一个类作为参数,并在此基础上将其添加到该类的数组列表中
- r - 如何更改因子值
- java - 如何将 java map 对象格式化为 groovy map
- java - 在两台电脑上运行游戏?
- c# - LoadSceneAsync 无法切换场景
- swiftui - @EnvironmentObject 通过 navigationLink 无法正常工作
- javascript - 问号后如何在url中获取变量输入(Javascript)