Question

When configuring Restler it suggests creating the following re-write rule:

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

I have put this into a .htaccess file in root of my REST directory but I'm getting a 500 Server error when this rule is being fired. The error message the apache error log is:

[Wed Oct 10 10:39:30 2012] [alert] [client 127.0.0.1] /public/api/.htaccess: RewriteCond: unknown flag 'QSA'
[Wed Oct 10 10:39:30 2012] [error] [client 127.0.0.1] File does not exist: /public/favicon.ico

I assume the lack of a favicon.ico file can be ignored but I am concerned about the "unknown flag 'QSA'" error. I know very little about rewrite rules so any help there would be appreciated.

For those familiar with Restler, I am using 3.0.0rc2 (if that matters). Also it's worth pointing out that using the explicit call to index.php works so much as I then get a 404 JSON error response (a positive improvement) but as indicated above if I rely on the rewrite rule then I just get a 500 Server Error:

http://localhost/api/index.php/say/hi    - WORKS (gives JSON 404 error)
http://locahost/api/say/hi               - 500 SERVER ERROR
Was it helpful?

Solution 2

Interesting ... I was looking into my JSON 404 message and found this post:

Restler always returns not found

It not only solved my 404 error but also helped to fixed the 500 Server error. The only thing I needed to do was change the http.conf's AllowOverride to All.

I'd still be interested if anyone could tell me WHY this is happening but the this does now work.

OTHER TIPS

  1. It doesn't look like the error has anything to do with the rules that you have:

    /public/api/.htaccess: RewriteCond: unknown flag 'QSA'

which says that the QSA flag is an unknown flag for a RewriteCond, followed by a favicon.ico not found so I'm guessing that it's unrelated to requests into your REST directory.

  1. If you had AllowOverride None, then your htaccess file is simply going to be outright ignored. There are different aspects of configuration options that can be overridden inside htaccess files, None means, htaccess cannot override any configurations, so it'll just get ignored.

  2. The QSA flag isn't needed at all here. You only need it when you are rewritting the query string and want to append the original query string to the end. By default, the query string is appended anyways.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top