Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess多个文件夹和根目录_Php_Angularjs_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php .htaccess多个文件夹和根目录

Php .htaccess多个文件夹和根目录,php,angularjs,apache,.htaccess,mod-rewrite,Php,Angularjs,Apache,.htaccess,Mod Rewrite,有人能帮我了解一下这种应用程序格式的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

有人能帮我了解一下这种应用程序格式的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
所以我基本上想要从root.htaccess文件中得到什么:

将以/api/开头的所有通信重定向到/api/*。这包括所有资产。 所有其他流量都要转到/src/*。 在/src/.htaccess中:我需要像往常一样在/src中查找所有文件请求,但所有url请求只需转到index.html重写规则^index.html[L]。 另外一个我很喜欢的功能:

url:mydomain.com/api/latest链接到预定义的文件夹,例如/api/1.0,或者如果有办法从文件夹名称中找到最新版本号,但让它计算,这可能会导致处理能力过大,因为它很容易硬编码,并且会有大量请求。 谢谢你的帮助。
提前谢谢。

我有点自己的解决方案,但请有人评论一下,让我知道这是好是坏,还是有更好的解决方案

干杯

/.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/api
RewriteRule ^(.*)$ /src/$1 [L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
/src/.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/api
RewriteRule ^(.*)$ /src/$1 [L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]