0
REST API首先我實現我的REST API重寫規則的Apache2的服務器上,使用下列.htaccess
文件:HTTPS與的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ index.php [QSA,NC,L]
</IfModule>
它工作得很好。如果我輸入了例如http://mypage.de/REST/SomeRule/12
我的index.php
在文件夾REST/
收到信息SomeRule/12
。
Now我啓用我的服務器上SSL
,我想force的API將會使用https
so添加以下碼至我.htaccess
文件中:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
現在我收到找不到錯誤的頁面。你能看到.htaccess
文件中的錯誤,或者它是否在其他地方?我對這些文件並不熟悉。要創建我的API,我使用了this tutorial。
您可以使用https:// domain.com/REST/SomeRule/12 URL直接訪問API嗎? – anubhava 2014-10-18 12:36:17
沒有嘗試過這一點。所以也許它不適用於我的api。就像我說的,我跟着我的問題中鏈接的教程。 – 2014-10-18 15:12:59
如果您使用'https:// domain.com/REST/SomeRule/12'獲得404,那麼您可能沒有正確設置SSL站點。爲https站點提供'VirtualHost'配置 – anubhava 2014-10-18 15:16:50