Jump to content

Getting 301 Moved Permanently status when accessing a page, also not getting GET parameters


adrianromega
 Share

Recommended Posts

Hello

I am trying to do a counter for page views that works also when a page has template cache applied, so I am using Ajax to request a certain page (sending also as GET parameter id with the id of the page for which I increment the field views).

I have used this method before, it worked perfectly, but now I cannot make it work... I am getting these problems...

1. The counter page that is accessed through ajax gets a 301 Moved Permanently status, not 200 OK status.

2. It does not get any GET parameters ($input->get->param nor $_GET)...

3. if I access the counter page directly in the browser, it works, I can access the $input->get or $_GET, my "views" field is being incremented, only when accessed with ajax it does not work...

I am using PW 3.0.36.

Please advise,

Link to comment
Share on other sites

Comparing the (ajax) request URL and the value of the Location: header sent back should normally clue you in to what is going wrong. Missing trailing slashes or missing language names in multilanguage URLs have been known culprits for such behavior, but there are probably dozens of possibilities that trigger a 301 redirect. If you pass an absolute, hard coded URL to the ajax request, a missing "www" in the domain name or a protocol mismatch (http vs https) might also lead to a redirect.

  • Like 3
Link to comment
Share on other sites

Hi BitPoet and thank you for your reply.

 

Your suggestion was good, I have found the problem.... first of all, it was because of multilanguage option and second, I did not want to load the entire counter page and I was requesting the page path using $page->getPath(id), which it seems it does not works as I imagined in multilanguage sites, it does not get automatically the url for a particular language....

  • Like 1
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...