所以我对我的角度应用程序有一堆.htaccess规则,我正在寻找这种行为:
如果存在dist / frontend.html,请将所有内容路由到该内容。如果没有路由到frontend.html。
这就是我现在拥有的。只要我请求子路由(例如http://www.domain.com/404/),规则就会起作用,但如果我要求root,没有路径就像这些规则永远不会执行它只依赖于DirectoryIndex
。
DirectoryIndex index.html index.html frontend.html index.php
# Rewrite everything which looks like it should be handled by angular here, 404 if a specific resource
RewriteCond %{REQUEST_URI} !\.(jpg|png|jpeg|gif|css|js|html)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/dist/frontend.html -f
RewriteRule ^ dist/frontend.html [L]
RewriteCond %{REQUEST_URI} !\.(jpg|png|jpeg|gif|css|js|html)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/frontend.html -f
RewriteRule ^ frontend.html [L]
答案 0 :(得分:0)
问题是这个条件:
RewriteCond %{REQUEST_URI} !\.(jpg|png|jpeg|gif|css|js|html)$ [NC]
由于您忽略了.html
扩展程序,并且使用index.html
作为默认处理程序使用DirectoryIndex
导致您的两个规则都被跳过。
如果您要使用其中一个frontend.html
使用其中一个规则,那么您实际上并不需要DirectoryIndex
指令,只需将其注释,它应该工作。