Search code examples
apacherestler

Restler setup not working


On my webserver running Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y I am trying to setup Restler but it can't seem to handle the index.php properly. This is a webapp setup with an httpd.conf that looks like so:

Alias "/dts2" "/usr/local/WebApps/DTS/root"

<Directory "/usr/local/WebApps/DTS/root">
  AllowOverride All
  Options -Indexes FollowSymLinks
</Directory>

So then I went into that 'root' directory and ran this command to install restler:

composer create-project restler/application=dev-basic api --prefer-dist

After that, in the 'api' directory I created my .htaccess file that looks like so:

DirectoryIndex index.php
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^$ public/index.php [QSA,L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ public/index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
    php_flag display_errors On
</IfModule>

And, finally when I try to access "https://..../dts2/api/Home/" to get the success message that restler provides, I get a 404 error.

What have I done wrong?


Solution

  • OK, finally got this working. There were two issues.

    One was Restler itself. The supplied index.php said $r->addAPIClass('Home', '');. I had to remove that second empty parameter.

    The other was apache. Instead of saying public/index.php on the RewriteRule I had to say /dts2/api/public/index.php.

    Once I made those two changes everything worked as expected.