Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Rewrite seems not to work correctly
 
danielczyk
Jr. Member
 
Total Posts:  7
Joined:  2012-07-09
 

I have installed Magento 1.7.0.2 on windows without problems.

On Linux everything was installed, but several urls or rewrite rules seem not to work.

For example http://v2201207129188828.yourvserver.net/magento/api/rest/products gives me always “Invalid webservice adapter specified.”

This indicates, that the “RewriteRule ^api/rest api.php?type=rest [QSA,L]” does not work.

When I use “RewriteRule ^api api.php?type=rest [QSA,L]”, it works, but won’t help later in REST communication.

Another indication is:
http://v2201207129188828.yourvserver.net/magento/admin/oAuth_authorize?oauth_token=
leads to “Whoops, our bad...” - so no response or bad url somehow.

Has anybody a hint? So somehow it is related to the REST functionality.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagenX
Enthusiast
 
Total Posts:  791
Joined:  2008-05-26
Dublin
 

have you tried to enable magento rewrites in admin? to remove /index.php/
have you configured rest api in magento admin?
do you have correct client settings to check this?

i just need more information.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chicurel
Jr. Member
 
Total Posts:  6
Joined:  2011-02-22
 

Hi Daniel,
I’m having the same problem with Windows 7 and xampp Apache 2.2.21
Did you solve the problem?
I have the same configuration and data in Linux and is working fine. Maybe it’s an apache (windows) problem?

Thanks!

Diego

 
Magento Community Magento Community
Magento Community
Magento Community
 
chicurel
Jr. Member
 
Total Posts:  6
Joined:  2011-02-22
 

Hi, I have find the ‘problem’ !
It was hard to see but I think that maybe this is the same situation.
In apache included with xampp the configuration to virtualhosts inside the <Directory> tag include the option ‘MultiViews’ (!)
http://httpd.apache.org/docs/2.2/content-negotiation.html#multiviews
With this option the server try to match any name without extension to a file in the directory.
For example, if I put the url:
http://www.example.com/test

it will look for a file inside the folder with that name, and an extension knowed.
For example, test.php

This option precede the Rewrite conditions, so I had activated the rewrite log, and find that the url that was trying to match with the rewrite rule had ‘.php’ in the path.
I try with : http://www.example.com/api/rest
And in the log it was saying:
“strip per-dir prefix: C:/xampp/htdocs/api.php/rest -> api.php/rest” (look that is adding the .php extension because there is a api.php file in the folder)
“applying pattern ‘^api/rest’ to uri ‘api.php/rest’ “ So.. the rule don’t match!

Then, the solution to me was add the -MultiViews option in Directory configuration: “Options Indexes FollowSymLinks -MultiViews”
I put explicit -Multiviews because don’t know if it is defined in other place. With this, the api/rest redirection is working fine!
If you don’t want to deactivate the Multiviews option (why?) I think that you could moddify the rule (or add a new one) to match in this case. Something like :
RewriteRule ^api(\.php)?/rest api.php?type=rest [QSA,L]
This is wroking fine too.

I hope this could help someone in same situation.

Regards

Diego

 
Magento Community Magento Community
Magento Community
Magento Community
 
intelliant
Jr. Member
 
Total Posts:  1
Joined:  2013-02-06
 

@chicurel

Have diagnosed and found that the value of “type” not being passed on the api.php is consistent with what has been found above as well as others in the posts below.

You seemed to have nailed this issue pretty well but I am yet grappling with it. have read and tried almost everything given in these links:
http://www.magentocommerce.com/boards/viewthread/288422/
http://www.magentocommerce.com/boards/viewthread/288718/#t414474
http://www.magentocommerce.com/boards/viewthread/279715/

I say almost as I am unable to get the Rewrite log written for debugging purposes. Have ensured that mod_rewrite is loaded. And this is how the /etc/apache2/conf.d/rewrite looks -

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3
but there is no sign of any log.

Additionally -

Firefox REST client’s GET requests are always returned XML and it returns the

406 Not Acceptable
response when we explicitly specify
Acceptapplication/json
in the FF REST client

CURL -

curl -X GET http://<base_url>/magento/api/rest/products
is always returned JSON and again returns the
406 Not Acceptable
response when we specify any Accept header.

Please do let me know if I can furnish any further information that shall help us resolve this.

Any help in this regard will be much appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
adrianalexan
Jr. Member
 
Total Posts:  3
Joined:  2012-11-11
 

This seems indeed to be a bug at least in 1.7.0.2 version. I’m really looking forward to see this officially reported.
So far the “workaround” is to use the XML delivered version.
I’ve seen this problem on ubuntu-12.04.2 (x32); on ubuntu-12.10-server-amd64, there are even more issues: the api cannot even be enabled.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMageTeam
Guru
 
Avatar
Total Posts:  356
Joined:  2013-01-13
Warsaw, Poland
 

Hello,

It seems that mod_rewrite is disabled. It can be enabled via the next command in Linux:
sudo a2enmod rewrite
In Windows you should open the configurable file Apache(httpd.conf) and find the line:
LoadModule rewrite_module modules/mod_rewrite.so
Then you should uncomment it. After these actions you should reload Apache.
You can get more information here:
http://www.magentocommerce.com/boards/viewreply/427178/

 
Magento Community Magento Community
Magento Community
Magento Community
 
adrianalexan
Jr. Member
 
Total Posts:  3
Joined:  2012-11-11
 
GoMageTeam - 27 February 2013 01:44 AM

Hello,

It seems that mod_rewrite is disabled. It can be enabled via the next command in Linux:
sudo a2enmod rewrite
In Windows you should open the configurable file Apache(httpd.conf) and find the line:
LoadModule rewrite_module modules/mod_rewrite.so
Then you should uncomment it. After these actions you should reload Apache.
You can get more information here:
http://www.magentocommerce.com/boards/viewreply/427178/

Sorry, this is not the case, at least in my situation smile
I heavily rely on rewrites for SEO…

 
Magento Community Magento Community
Magento Community
Magento Community
 
janirx
Jr. Member
 
Total Posts:  1
Joined:  2013-03-23
 
adrianalexan - 16 February 2013 12:47 PM

This seems indeed to be a bug at least in 1.7.0.2 version. I’m really looking forward to see this officially reported.
So far the “workaround” is to use the XML delivered version.
I’ve seen this problem on ubuntu-12.04.2 (x32); on ubuntu-12.10-server-amd64, there are even more issues: the api cannot even be enabled.

If someone still has problems with this, I had the same problem and found out that the Accept header must include */*;q=0.8 in addition to application/json for it to work. Otherwise magento gets a fit and gives 406.

So header:
Accept: application/json,*/*;q=0.8

I suppose quality parameter can be anything < 1.

That’s why you get xml when not specifying Accept header since standard header includes application/xml

Hope this helps someone.

 
Magento Community Magento Community
Magento Community
Magento Community
 
artur2000
Jr. Member
 
Total Posts:  2
Joined:  2009-11-13
 

I can confirm that the both solutions from chicurel (switching off MultiViews in Apache config) and from janirx (Header Accept: application/json,*/*;q=0.8) work independently.

Me to I got the following result trying $Oauth::fetch() (PECL 1.2.3) with GET

Invalid auth/bad request (got a 406expected HTTP/1.1 20X or a redirect)
Not Acceptable

An appropriate representation of the requested resource 
/api/rest/products could not be found on this server.
Available variants:

    
api.php type application/x-php

After analysing the debug output from the Oauth client ($Oauth->debugInfo[’sbs’]) I noticed that the URL is at least for me some kind of strange, because the “?” delimiter is missing before all the GET parameters and it is required as far as I know without checking.

http://magento-host/api/rest/products&oauth;_consumer_key=1ng28mfsvli1lvaquf8hj64g8fntyutm&oauth;_nonce=...

If I try to fetch this URL with cURL instead of Oauth::fetch() I get 404, if I add this “?” I get the correct JSON array with products.

This missing ? might play a role in this behavior.

Anyway with the solution from chicurel or janirx it works even that way.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jadav1982
Jr. Member
 
Total Posts:  7
Joined:  2013-06-21
 

I am also getting same issue with IIS 7. I have write below code for URL Rewrite

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=\"Remove index.php Rule\” stopProcessing=\"true\">
<match url=\".*\" ignoreCase=\"false\" />
<conditions>
<add input=\"{URL}\" pattern=\"^/(media|skin|js)/\" ignoreCase=\"false\" negate=\"true\" />
<add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" ignoreCase=\"false\" negate=\"true\" />
<add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" ignoreCase=\"false\" negate=\"true\" />
</conditions>
<action type=\"Rewrite\" url=\"index.php\" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

What I should add rule for REST API call in my code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
NELAGeek
Sr. Member
 
Avatar
Total Posts:  193
Joined:  2010-01-23
US
 

in your httpd.conf, if you don’t have allowoverride = all, the .htaccess in your Magento directory is useless.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top