我有一个angular2应用程序,它击中了api
,它放在我的wamp/www
中。当我尝试点击api时,我会得到这个错误。
404 Not Found 未找到在此服务器上找不到请求的URL /usmanproject/api/web/v1/user。
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80
我的“角”应用程序正在localhost:4200
上运行,“角项目”文件夹也放在wamp/www
中,但它不能工作。
这是我的角码
private heroesUrl = 'http://localhost/usmanproject/api/web/v1/users?access-token=n-EJtZiejtz5RSVWe-U14G4kCnPWMKf0'; // URL to web api
private headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
create(): Promise<any> {
return this.http
.get(this.heroesUrl)
.toPromise()
.then(res => res.json().data)
.catch(this.handleError);
}
后端是yii2
制作的。我在邮递员中测试过api
http://localhost/usmanproject/api/web/v1/users?access-token=n-EJtZiejtz5RSVWe-U14G4kCnPWMKf0
,它在那里工作得很好。
它在google chrome上运行得很好,但在firefox上却不行。
发布于 2019-09-05 13:17:32
您需要检查虚拟主机重定向项目的位置。在角度上,它将在dist/projectName/上重定向,在那里您应该添加一个.htaccess,它应该如下所示:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
https://stackoverflow.com/questions/46212554
复制相似问题