Forum
Problem with file path
This may just be me as I have always had a block when it comes to file paths, but on my local server (i.e. where I am building a site) I am calling a cart functions script, which I have put into the Paypal Shop directory, from a jQuery Ajax call and all works fine. However I have uploaded the files to my client area [directory / sub-domain] on my live site and no matter what variation I try I cannot get the file path to work (varying errors depending on what I try).
The Ajax call is made from
/shop/category-name/product-name on my local machine
The jQuery file (that has the Ajax call) is located in
/assets/js/shop.jquery.min.js
The shopping cart functions are in
/perch/addons/apps/perch_shop_paypal/cart.functions.php
And in my jQuery file I am trying to access using
/perch/addons/apps/perch_shop_paypal/cart.functions.php
As I say this works fine on my localhost but not on my remote server and I don't know why or if it is just to do with being on a sub-domain. Can anyone help?
What errors are you getting?
With /perch/addons/apps/perch_shop_paypal/cart.functions.php I get
https://www.client.my-site.co.uk/perch/?r=%2Fmanage%2Faddons%2Fapps%2Fperch_shop_paypal%2Fcart.functions.php 403 (Forbidden)
Which I find a bit odd in itself that it is replacing the forward slashes.
I have tried other variations of the path but will stick with this one for the moment.
403 (Forbidden).
Looks like a server configuration issue so you should take that up with your host.
OK, but can you confirm this is the correct path structure you would use in this situation please?
Sorry to come back to you about this but I am now pulling my hair out. My hosting company says it isn't the server (though I am never quite sure I believe them) and that it is to do with my .htaccess file and I just can't see a problem with it and I still have no idea what would cause the html entity replacement in the url (I have never seen it before).
Is anyone able to cast an eye of my .htaccess file and let me know if they can see any issues that might be causing this problem please (dog-agility-equipment is the name I have given my shop directory)?
Your script is being redirected to the Perch login page - hence the 403 status and the encoded querystring.
I can think of two possible reasons:
The URL you're requesting is part of the Perch control panel and your JavaScript request isn't authenticated
You're requesting the correct URL, but a bad rewrite rule is redirecting it to part of the Perch control panel.
Did you rename the
perch
folder tomanage
or is that a typo? Could that be the cause?Yes I thought that odd as well and forgot to mention it as it only happens when I call the script directly from the form (i.e. I have commented out the jQuery / Ajax call so that I can test more easily) and just thought it was something to do with whatever the issue is in the first instance.
When you say the url I am requesting is part of the control panel, can you explain a bit more please - do you mean because the file I am trying to access is within the Perch folder?
I would say the 2nd is the issue but I can't see anything wrong with my rewrite rules which is why I am completely baffled (I also don't understand why it works perfectly fine on localhost and the issue has only arisen since I have uploaded to a remote server).
I have renamed the Perch folder to manage (just so it makes more sense to the client). Would this cause the problem as I thought I could rename the folder?
It doesn't make a difference, only that you said your paths were all
/perch
.But this really doesn't make sense:
I'm trying to figure out how you'd access a page under
/manage
and then get redirected to log in at/perch
. Have you updated yourconfig.php
file to reflect the renaming?Sorry, I changed to perch in my first post to have it make more sense (i.e. so you would know the paths) I should have just used what I use and explained that I had renamed the directory.
So actually what I get is
What does
cart.functions.php
do? Does it attempt to include any parts of Perch?cart.functions.php does all the 'stuff' for adding to, editing and deleting from the shopping cart using both sessions and also adding and updating cookie data both on the users machine and within the database. I have created a couple of classes and used other scripts for the Paypal shop as an example to create the script.
This is what I have at the top of the script (the rest is just properties and methods for the cart):
I also have some additions to the main runtime file which checks if a cookie has been stored on the users computer each time they visit the site, which is:
Not sure if any of this has a bearing on the problems I am having on the remote server - and still confused as to why it works fine on localhost??
Anyone?
I'm not sure how to help, as so much of this is your code rather than mine.
Starting with basics, can you see the HTTP request going to the correct URL? If you GET that URL yourself in a browser or with cURL, what happens?
Well that is really strange. The HTTP request is going to the correct URL, however the status code says 302 Moved Temporarily (I have tried a couple of locations for the file and both state the same).
Then it appears that the url is changed to
Which then returns a 403 Forbidden.
If I try to go directly to the URL I get exactly the same header / response.
Unfortunately I don't know how to GET the URL with cURL. Any pointers?
OK, I have now done some more debugging and found that it is my call to
Which is causing the issue. As I have copied the includes directly from the requirements for add-on apps and this file is within the Paypal app folder, why would this be causing an issue?
Finally have this sorted. I have changed the include files to match that of the Paypal IPN callback and all is now working as it should.
Took a long time to get there but thank you Drew for your help as it made me think of other things and ways of debugging the problem which has led to resolving it :)