This will be a short one. As our public-facing applications age and new applications are developed to replace them, we often have the problem that search engines still send people to the old application pages.
One way of solving this issue, and of giving some feedback to the search engines so that they will update their indexes, is by using the HTTP Response Status Code 301 "Moved Permanently". Any self-respecting search engine that receives this response code will remove the outdated link from their index. Also, any users that click on the old link will be automatically redirected to the new one.
Let's take an example: suppose that I have an old APEX application (e.g. app ID 88203) and I want to redirect people to the Universal Theme application (App ID 42) instead of my old page.
The only thing that I need to do is to add a "Before Header" PL/SQL process. Let's call this process "Permanent Redirect".
This process does three things:
Here's the PL/SQL code for the process:
One way of solving this issue, and of giving some feedback to the search engines so that they will update their indexes, is by using the HTTP Response Status Code 301 "Moved Permanently". Any self-respecting search engine that receives this response code will remove the outdated link from their index. Also, any users that click on the old link will be automatically redirected to the new one.
Let's take an example: suppose that I have an old APEX application (e.g. app ID 88203) and I want to redirect people to the Universal Theme application (App ID 42) instead of my old page.
The only thing that I need to do is to add a "Before Header" PL/SQL process. Let's call this process "Permanent Redirect".
This process does three things:
- it sets the http status to 301
- it redirects to the new url
- then it immediately halts all APEX execution by stopping the apex engine
Here's the PL/SQL code for the process:
owa_util.status_line(301,'',false);
owa_util.REDIRECT_URL('https://apex.oracle.com/pls/apex/f?p=42:100', true);
apex_application.stop_apex_engine();
Before Header process to be created - Permanent Redirect
The Permanent Redirect process definition
You can see it working here: https://apex.oracle.com/pls/apex/f?p=88203:1::::::
One online tool that I found useful while testing this approach was https://httpstatus.io/, it's an online tool to easily check status code, response headers and redirect chains.
I hope that this comes in useful to you one of these days. It's a quick and relatively simple approach to solving a common problem.
Thanks for sharing this useful tip!
ReplyDelete