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