How To Achieve A 302 Redirect After AJAX Post? Trying To Implement Prg-pattern
I am trying to implement a "post request get" pattern for SEO reasons like explained in this example: https://www.advertising.de/seo/wiki/prg-pattern.html
My implementation consits of a pseudo link element, styled via CSS like a link:
<span data-prg="redirect_url.html" class="btn redir-link" title="test">PRG Link test</span>
A jquery AJAX POST call
Th PHP file that will create the redirect URL and which should 302 redirect via GET
header("Location:".$_POST['url'], true, 302); exit;
The apache log states that the implementation works:
"POST /prg.php HTTP/1.1" 302 "GET /redirect_url.html HTTP/1.1" 200
However the page inside the browser does not change. I suspect that the php file that is called via ajax will change but this is not what I want. The orginial page should be redirected.
How could I accieve a 302 redirect for the original page?
You can't redirect in a ajaxed page the page isn't available for the user,do a simple form that will trigger a post request to
/prg.php in prg you then redirect back
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?