Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Apache 角度2+;Nginx深度链接/路由问题_Apache_.htaccess_Angular_Nginx - Fatal编程技术网

Apache 角度2+;Nginx深度链接/路由问题

Apache 角度2+;Nginx深度链接/路由问题,apache,.htaccess,angular,nginx,Apache,.htaccess,Angular,Nginx,我在Apache web服务器上部署了一个Angular2应用程序,并使用以下.htaccess <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRul

我在Apache web服务器上部署了一个Angular2应用程序,并使用以下.htaccess

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^ index.html [L]
</IfModule>

选项+FollowSymlinks
重新启动发动机
RewriteCond%{REQUEST_FILENAME}-f[或]
RewriteCond%{REQUEST_FILENAME}-d
重写规则^-[L]
重写规则^index.html[L]
以及index.html中的附加配置

<base href="/applicationName/">

应用程序能够加载,没有任何问题,也没有重定向问题

我现在正试图在我的Nginx服务器上安装相同的应用程序,但似乎无法使其正常工作

我知道Nginx中没有.htaccess,如何将上面的.htaccess转换为在Nginx主配置中工作


非常感谢

在我看来,Nginx实际上比apache容易得多。一种方法是像这样创建一个服务器块。当然,如果您有权访问服务器上的nginx配置文件,就可以访问该文件

server {
    listen       80;
    server_name  example.com;

    root   /path/to/your/index;
    index index.html;

    location / {
      try_files $uri $uri/ /index.html;
    }
}

嗨,Pierre,我在默认配置文件中尝试了上述块,但仍然没有成功。我能够加载主索引页,但当我尝试执行一个过程时,例如登录,我得到错误500,==>/var/log/nginx/error.log啊,另一件需要注意的是,在同一台服务器上会运行多个应用程序,因此,根被设置为/var/www/html作为主文档根,我会在浏览器地址栏的/之后添加应用程序名。有人吗?谢谢此后,该问题已完全记录在角度文档中: