mod-rewrite - 使用 apache 重写的 Angular7 无法正常工作
问题描述
我有我的角度应用程序7.1.4
在 apache2.4.10
服务器上运行。我PathLocationStrategy
用来路由我的网址。
这是我的 index.html 文件的一瞥
<meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Expires" content="0" /> <title>Intranet</title> <base href="/">
.htaccess 文件
选项 +FollowSymlinks
重写引擎开启
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
重写规则 ^ - [L]
重写规则 ^ /index.html [L]
问题是,如果我的网址看起来像
http://intranet.company.com/app/myspace?id=favorites
阿帕奇重定向到
http://intranet.company.com/index.html?id=favorites
并且我的目标页面没有显示。
知道我的 URL 都以BASE_URI/app/...
解决方案
删除 index.html 的 / 前面
RewriteRule ^ index.html [L]
推荐阅读
- rest - HTTP和Rest有什么关系?
- swift - 如何在单击分段控件之前对视图进行更改?
- delphi-xe3 - Delphi - SQL Server 查询需要很长时间才能运行
- types - 为什么我会因为缺少类型注释而收到错误“特征绑定 FromStr 不满足”?
- django - 子类化基于类的视图时没有httpresponse
- dart - 强制用户显式声明变量
- ruby-on-rails - Rails 6 ActionCable/Redis 生产配置
- laravel - 如何获取当前动作(方法)名称?
- java - 在外部 Tomcat 服务器上运行的 Springboot 在除 index.html 之外的所有内容上都会出现错误 404
- c# - 为什么我的与 DTO 相关的 Swagger.JSON 不会根据正在更新的 API.XML 文件中的定义进行更新?