0
這是我的文件夾結構:AngularJS + PHP API
myproject/
api/
api.php
public/
.htaccess
index.html
scripts/
... all my angular stuff...
我的.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]
RewriteRule ^/api/ ../api/api.php
# If the requested resource doesn't exist, use index.html
RewriteRule^/index.html
所以,我想這樣的:訪問http://localhost
剛剛返回我的index.html
。但是,我的AngularJs代碼中的Ajax調用/api/something
應該由我的api.php
文件處理。
目前,我的Apache虛擬主機指向myproject/public
。訪問http://localhost
工作正常(它返回index.html),但我的電話/api/something
也返回index.html。看來api.php
永遠不會到達。有任何想法嗎?
作爲我懷疑,當你打apa時,相對論不會奏效che,看到這個可能的解決方案../api:http://stackoverflow.com/a/21324642/3802077 – user3802077
酷。我會在到家時嘗試。謝謝! –