html - 将我的根 url 映射到子目录
问题描述
我的问题很简单:如何将我的 url root 别名为我的子目录之一?
假设我网站的网址是
https://example.com
我的文档根目录是
/home/user/web
但是,我想通过上面的 URL 来访问
/home/user/web/app
我似乎无法使用
Alias / /app/
我尝试按照这个类似的答案 [here] ( .htaccess: Redirect root url to subdirectory, but retain root url ) 添加
RedirectMatch 301 ^/app/.*$ https://example.com/
我最终会得到:
This page isn’t working
example.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
我该怎么办?
解决方案
您可以访问 httpd.conf 吗?然后你可以简单地改变 DocumentRoot
DocumentRoot "/home/user/web/app"
或者,如果您在那台机器上有更多域,请使用虚拟主机。或重写:
RewriteEngine On
RewriteRule ^(.*)$ %{HTTP_HOST}/app/$1 [R=301,L]
或重定向匹配:
RedirectMatch 301 ^/$ https://example.com/apps
另一种选择是文件系统上的符号链接。
首先尝试不使用 https - 查看普通的 http 工作。
推荐阅读
- android - 如何在 kotlin Android 中访问更大的 jsonArray json 中的 json 数组中的字符串
- linux - 在 Linux 文件系统中大小 8E 是什么意思?
- html - 将附加组件添加到表中的 tr 元素
- php - 数学/比较检查不起作用
- javascript - 将新原型分配为 InheritingClass.prototype = Object.create(InheritedClass.prototype)
- mysql - 如何为 mariadb、node.js 和 websockets 创建准备好的语句
- java - 在 GUI 设计中难以将数组列表的值加载到 Jcombobox 中
- android - 我正在尝试从手机中获取音频文件,但我的应用无法获取文件,因为我编写了这行代码帮助我找到解决方案
- mysql - 在 SQL 查询之外导出值(回调地狱)
- javascript - 如何在不使用特定 ID 的情况下使用 jsPDF 生成 pdf