Mik*_*aas 21 apache mod-rewrite rewrite angularjs
显然,整个网络上都有很多mod重写讨论和答案.但是,我很难抓住它们.所以我想我会问这里.
我要求重写规则来做Andy Joslin在评论中解释的内容:https://stackoverflow.com/a/11100438
这是我在example.com根目录下的当前dir结构
我想将所有请求重定向到app/index.html,除了对/ api的请求.
例如:
http://example.com/categories/electronics/ipod实际上就像去http://example.com/app/index.html/categories/electronics/ipod
我想隐藏app/index.html部分.
然后,对http://example.com/api的请求会有例外,因为我需要向这些url路径发出ajax请求.
感谢您提供的所有帮助/指导.
Sco*_*son 24
这个问题的公认答案已经过时了.您现在可以在Apache 2.2.16+的conf文件中使用FallbackResource指令.
FallbackResource /app/index.html
Run Code Online (Sandbox Code Playgroud)
如果您希望FallbackResource指令忽略"/ api"路由:
<Directory /api>
FallbackResource disabled
</Directory>
Run Code Online (Sandbox Code Playgroud)
Ste*_*wie 15
这里有一些东西让你去(把它放在你的/.htaccess文件中):
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api
# otherwise forward it to index.html
RewriteRule ^.*$ - [NC,L]
RewriteRule ^app/. /app/index.html [NC,L]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24984 次 |
| 最近记录: |