为同一服务器上的 angular 2 个应用程序和 Web 服务重写规则

Re-write rule for angular 2 app and web service on same server

我需要更正下面的重写规则,以便调用的任何 url 都将定向到 / 或 index.html,但如果 url 用于 Web 服务( /ws/controller/function) 然后我希望它指向 /ws/index.php

对于我的 angular 2 在 html 我有

<base href="/">

而 url 的格式是 xxx/yyy/ 而不是 #/xx/yy

我的 .htaccess 是

<ifModule mod_rewrite.c>
RewriteEngine on
Options FollowSymLinks

RewriteBase /ws/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ws/index.php?url= [L,QSA]
</ifModule>

<ifModule mod_rewrite.c>

RewriteEngine On 
Options FollowSymLinks

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/ [L]

</ifModule>

它按原样运行良好,但当用户在除根目录以外的任何其他位置重新加载页面时,应用程序就会崩溃。

谢谢

我认为这会有所帮助:

<ifModule mod_rewrite.c>

RewriteEngine On
Options FollowSymLinks

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/ws/
RewriteRule ^(.*)$ index.html [L,QSA]

RewriteRule ^(ws/.*)$ ws/index.php?request= [L,QSA]

</ifModule>