因此,对于我的角度应用程序,我有一堆.htaccess规则,我正在寻找行为:
如果dist/Fronten.html存在,则将所有内容路由到该位置。如果不路由到frontend.html。
这就是我现在所拥有的。只要我请求一个子路由(例如http://www.domain.com/404/),规则就能工作,但是如果我请求根,没有路径,就好像这些规则从未被执行过,它只是依赖于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]
发布于 2015-01-14 10:16:07
问题是这种情况:
RewriteCond %{REQUEST_URI} !\.(jpg|png|jpeg|gif|css|js|html)$ [NC]
因为您忽略了.html
扩展,也使用了index.html
作为默认处理程序,所以使用DirectoryIndex
会跳过这两个规则。
如果要使用2条规则中的一条使用frontend.html
,那么您实际上不需要DirectoryIndex
指令,只需注释掉,它就会工作。
https://stackoverflow.com/questions/27949447
复制相似问题