【问题标题】:Angular7 rewrite with apache not working correctly使用 apache 重写的 Angular7 无法正常工作
【发布时间】:2019-10-16 02:49:06
【问题描述】:

我的 Angular 应用程序 7.1.4 在 apache 2.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

Apache 重定向到

http://intranet.company.com/index.html?id=favorites

我的目标页面没有显示。

知道我的 URL 都以 BASE_URI/app/... 开头,我该如何解决这个问题

【问题讨论】:

    标签: mod-rewrite url-rewriting angular7 apache2.4 angular7-router


    【解决方案1】:

    删除index.html前面的/

       RewriteRule ^ index.html [L]
    

    【讨论】:

    • 还是同样的问题。
    猜你喜欢
    • 2012-11-13
    • 1970-01-01
    • 2023-03-31
    • 2016-12-01
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-22
    相关资源
    最近更新 更多