我建立了一個REST API和終點重寫是MOD清潔API終點
/var/www/site/restapi/v1
現在我設置類似
Alias /api/v1 /var/www/site/restapi/v1
因此,如果虛擬主機配置我使用url http://site.com/api/v1它退到裏面/restapi/v1
但是,index.php文件API調用可以像
http://site.com/api/v1/Auth/login和處理,我把.htacess
內/restapi/v1
作爲
RewriteEngine On
RewriteRule ^(.*)/(.*) index.php?resource=$1&method=$2
而且這是行不通的。我做了一些研究,發現在虛擬主機的配置,如果我改變
Options Indexes FollowSymLinks MultiViews
到
Options Indexes FollowSymLinks
然後,它的工作原理,但問題是,當我使用GET則變得
獲取資源"Auth/login"
如何添加清潔API網址,而不必刪除多視圖,並使用與
重新寫
你的意思是「它變成了」Auth/login「」?這句話對我來說沒有多大意義。此外,嘗試比「不行」更具體 - 描述發生了什麼。 – Artefacto
確認「Auth/login」意味着在/ restapi/v1裏面我有index.php文件,當我使用$ resource = $ _GET [「resource」] $資源包含「Auth/login」時,多視圖。如果我保持多視圖,然後我得到404頁未找到錯誤。 –
以下是我稱爲api方法的示例,網址爲http://site.com/api/v1/Auth/login。在虛擬主機中,我有Alias/api/v1/var/www/site/restapi/v1,並在restapi/v1文件夾內有index.php文件。 index.php獲取資源和方法的值,爲此,我在./ restapi/v1中添加了帶有重寫規則的.htaccess作爲RewriteRule ^(。*)/(。*)index.php?resource = $ 1&method = $ 2。 –