Tuesday 03 July 2012 4:15:26 pm - 9 replies
Hi,
First off, sorry if this should have gone in the New API forum. I wasn't sure if it counted as that or configuration.
I'm trying out the eZ REST part and when I go to:
http://......./api/ezp/content/node/2/list
I get a 400 Bad Request response, but when I go to:
http://......./index_rest.php/api/ezp/content/node/2/list
It works fine. Turning on the rewrite log doesn't show what's going wrong, it just raises another question in why the 2nd one hits two rules when both have a [L] at the end. Here is the output of the log, any ideas?
(2) init rewrite engine with requested uri /api/ezp/content/node/2/list (3) applying pattern '^/api/*' to uri '/api/ezp/content/node/2/list' (2) rewrite '/api/ezp/content/node/2/list' -> 'index_rest.php' (2) local path result: index_rest.php (2) init rewrite engine with requested uri /index_rest.php/api/ezp/content/node/2/list (3) applying pattern '^/api/*' to uri '/index_rest.php/api/ezp/content/node/2/list' (3) applying pattern '^/index_rest\.php' to uri '/index_rest.php/api/ezp/content/node/2/list' (1) pass through /index_rest.php/api/ezp/content/node/2/list (2) init rewrite engine with requested uri /api/ezp/content/node/2/list (3) applying pattern '^/api/*' to uri '/api/ezp/content/node/2/list' (2) rewrite '/api/ezp/content/node/2/list' -> 'index_rest.php' (2) local path result: index_rest.php
Wednesday 04 July 2012 9:22:24 am
HI.
In both possibilities above, if the pattern did trigger a match then there would be confusion about why the [L] would not stop the matching (unless therea re stray additional ReqriteEngine On directives, which, I believe, will reset the parser).
A 400 error further suggests that the answer is in your final rewrite rule as 400 is related to some jumbled/messed up request, so I suspect that the final rewrite is somewhat mangled.
The answer will most likely be more apparent if we don't have to make assumptions about the exact way the rewrite rules are applied. So, without exposing anything super-secret, could you please upload your rewrite rules as you have them in your .htaccess or xxx.conf file?
Regards,
David
Modified on Wednesday 04 July 2012 9:24:21 am by David Ennis
Wednesday 04 July 2012 10:06:03 am
Thanks.
Here are the current RewriteRules:
RewriteRule ^/api/ index_rest.php [L]
RewriteRule ^/index_rest\.php - [L]
RewriteRule ^([^/]+/)?content/treemenu.* index_treemenu.php [L]
RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L]
RewriteRule ^/var/([^/]+/)?cache/(texttoimage|public)/.* - [L]
RewriteRule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^/share/icons/.* - [L]
RewriteRule ^/extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L]
RewriteRule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteRule ^/packages/styles/.+/thumbnail/.* - [L]
RewriteRule ^/var/storage/packages/.* - [L]
RewriteRule ^/favicon\.ico - [L]
RewriteRule ^/w3c/p3p\.xml - [L]
RewriteRule .* /index.php
Wednesday 04 July 2012 1:59:50 pm
No sub folders. It just goes straight into /api eg. http://domain.com/api
Wednesday 04 July 2012 3:53:22 pm
Quote from Jon Staines :Thanks.
Here are the current RewriteRules:
RewriteRule ^/api/ index_rest.php [L]
RewriteRule ^/index_rest\.php - [L]
RewriteRule ^([^/]+/)?content/treemenu.* index_treemenu.php [L]
RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L]
RewriteRule ^/var/([^/]+/)?cache/(texttoimage|public)/.* - [L]
RewriteRule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^/share/icons/.* - [L]
RewriteRule ^/extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L]
RewriteRule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteRule ^/packages/styles/.+/thumbnail/.* - [L]
RewriteRule ^/var/storage/packages/.* - [L]
RewriteRule ^/favicon\.ico - [L]
RewriteRule ^/w3c/p3p\.xml - [L]
RewriteRule .* /index.php
Rewrite rules can be tricky depending on other modules and configurations.
some permutations that may work for you:
NOTE: for my setup, the first is probably right, but for others, the second one (leading slash). For others, some other version in a similiar fashion. Yes, the pattern match and replacement with the $1 should not be needed, but I find that the above is safest against variations in server setup.
NOTE: in your version, you are missing the content that you want to add the 'additional_path_info' with (path info after the file index_rest.php)
NOTE: even if the above for you were meant to work, you consume the leading slash in your apttern match and then do not start the replacement with a leading slash (you have "index_rest.php" instead of "/index_rest.php"
, so the server will rewrite that to [root]/index_rest.php -p in my case /var/www/index_rest.php
NOTE: Why the R=302? I use the 302 redirect modifier so that I can debug by seeing what the rewrite is. I often use this in conjunction with wget in debug mode
Wednesday 04 July 2012 4:27:16 pm
Quote from Jon Staines :Many thanks, it now works. In the end I've needed this:
RewriteRule ^/api/(.*) /index_rest.php/api/$1 [NC,L]
I removed the R=302 once it was working.
WhoHoo!! And another one hit out of the park
Glad we could help.
-David
You must be logged in to post messages in this topic!