如何使用htaccess angular 4产品重定向除两个文件夹内容以外的所有请求

时间:2018-11-01 18:31:13

标签: php angular .htaccess

老兄,我按照有角度的官方页面上的说明使用它们提供的htaccess部署到我的应用程序中,这一切都很好,但是在同一服务器上,我在2个文件夹中有webservices,我需要htaccess忽略这些细节uri的内容

角度页面有htaccess

RewriteEngine On
    # If an existing asset or directory is requested go to it as it is
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]
    # If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

有地雷

RewriteEngine On
    RewriteCond %{REQUEST_URI} "/webservices/" [OR]
    RewriteCond %{REQUEST_URI} "/MOAES/"
RewriteRule (.*) $1 [L]
    # If an existing asset or directory is requested go to it as it is
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]
    # If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

1 个答案:

答案 0 :(得分:0)

我解决了此问题,包括在条件-f标志中,以允许该目录上的档案

RewriteEngine On
    RewriteCond %{REQUEST_URI} "/webservices/" -f [OR]
    RewriteCond %{REQUEST_URI} "/MOAES/" -f
    RewriteRule (.*) $1 [L]
    # If an existing asset or directory is requested go to it as it is
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
    RewriteRule ^ - [L]
    # If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html