【发布时间】:2014-09-22 08:41:20
【问题描述】:
有人可以帮我制定此应用程序格式的 htaccess 规则吗?
这是我的文件结构:
/api
- /1.0 (this is a php project, a backend rest api of sorts to the frontend)
- /other-php-folders
- /...(lots of stuff)
- /public
- /...(lots of assets etc)
- /index.php
- /.htaccess (ignore for now)
/src (this contains an angularjs compiled website)
- /assets
- /cool-asset.js
- /cool-asset2.css
- /cool-asset3.png
- /index.html
- /.htaccess
/.htaccess
所以我基本上想从根 .htaccess 文件中得到什么:
- 将从“/api/”开始的所有流量重定向到“/api/*”。这包括所有资产。
- 所有其他流量都转到“/src/*”。
- 在 /src/.htaccess 中:我需要像往常一样查看 /src 中的所有文件请求,但所有 url 请求只需转到 index.html (RewriteRule ^ index.html [L])。
还有一个我很喜欢的好功能:
- url: mydomain.com/api/latest 链接到预定义文件夹(例如 /api/1.0),或者是否有办法从文件夹名称中找到最新版本号(但让它计算这可能是太多的处理能力,因为它很容易被硬编码,并且会有很多请求)。
任何帮助表示赞赏。 提前致谢。
【问题讨论】:
标签: php angularjs apache .htaccess mod-rewrite