Jump to content

Webservice error


Recommended Posts

Hi,

 

I have just installed Prestashop 1.6, I can access to the shop and back-end, but not webservice.

 

When I access "http://localhost/prestashop/api/" or "http://dev.prestashop.com/api/", I got a 404 Not found page with :

 

The requested URL /prestashop/webservice/dispatcher.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

Every files/folder in prestashop folder are owned by www-data:www-data.

 

More over, I have :

  • enabled curl, php5-curl, mod_rewrite
  • enabled Prestashop's webservice
  • generated webservice key and checked every checkbox in "Resource"
  • created a virtual host because I work locally

My dev.prestashop.com.conf virtual host contains :

<VirtualHost *:80>
	ServerName dev.prestashop.com
	DocumentRoot /var/www/prestashop/
    	<Directory /var/www/prestashop/>
        	Options FollowSymLinks Indexes MultiViews
        	AllowOverride All
    	</Directory>
</VirtualHost>

When I enable "Friendly URL" in SEO, I cannot access no more the front-end shop, because I got this error :

Not Found

The requested URL /prestashop/en/ was not found on this server.

 

, and sometimes I get errors in back-end like :

2 errors 

  1. The route is not valid
  2. Route to modules : Incorrect value

 

And then, when I access thoses previous webservice URL, I got a 500:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

 

The Apache error.log contains :

 AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

 

So I've checked and re-generateed the .htaccess, and it contains :

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>

RewriteEngine on


#Domain: localhost
RewriteRule . - [E=REWRITEBASE:/prestashop/]
RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# Images
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]

# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
<IfModule mod_headers.c>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$">
		Header add Access-Control-Allow-Origin "*"
	</FilesMatch>
</IfModule>

#If rewrite mod isn't enabled
ErrorDocument 404 /prestashop/index.php?controller=404

Finally, when I access "http://localhost/prestashop/webservice/dispatcher.php", and put the webservice key, I successfully got a .xml with :

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<api shopName="JacquesTest">
<addresses xlink:href="http://localhost/prestashop/api/addresses" get="true" put="true" post="true" delete="true" head="true">
<description xlink:href="http://localhost/prestashop/api/addresses" get="true" put="true" post="true" delete="true" head="true">The Customer, Manufacturer and Customer addresses</description>
<schema xlink:href="http://localhost/prestashop/api/addresses?schema=blank" type="blank"/>
<schema xlink:href="http://localhost/prestashop/api/addresses?schema=synopsis" type="synopsis"/>
</addresses>
...

Of course, I cannot access "http://localhost/prestashop/api/addresses", so I can't do anything.

 

 

 

I don't know what to do now, do you have an idea about my problem ?

 

Thank you in advance ! :)

Edited by MrAurora (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
Hi,

 

I spend 2 hours on this problem and I solved it by htaccess on the root directory.

 

I saw that line alone : 

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

 

I just add this before :

RewriteCond %{HTTP_HOST} ^yoururl.com$

 

Now it works

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...