The challenge for Noordlease is that we have a listing page which shows all the autos. For each auto, a new dynamic page will be generated which has a query parameter in it to show the auto information.

If the visitor removes the auto id number, it shows a page without the HubDB raw data. this is not good for SEO.

On the other hand, the sitemap is also filled with unrelated pages that should not be filled.

The code below is added to the individual auto page in the header which redirects the URLs without having an auto_id in their slug to a mentioned URL.

{% set auto_id = request.query_dict.auto_id|int %}
{% set is_editor = request.postDict.inpageEditorUI %}

{% if auto_id %}
  {% set row = hubdb_table_row(62135025, auto_id) %}
{% elif not is_editor %}
  <meta http-equiv="refresh" content="0;url=https://144575582.hs-sites-eu1.com/aanbod" />
{% endif %}

  • {% set auto_id = request.query_dict.auto_id|int %}
    • Retrieves the auto_id from the query string and converts it to an integer.
  • {% set is_editor = request.postDict.inpageEditorUI %}
    • Retrieves the inpageEditorUI value from the post data of the request.
  • {% if auto_id %}
    • Checks if auto_id is set (i.e., not zero or null).
  • {% set row = hubdb_table_row(62135025, auto_id) %}
    • If auto_id is set, retrieves a row from the HubDB table with the specified ID and auto_id.
  • {% elif not is_editor %}
    • If auto_id is not set and is_editor is not present in the post data:
  • <meta http-equiv=”refresh” content=”0;url=https://144575582.hs-sites-eu1.com/aanbod” />
    • Adds a meta tag to redirect the user to the specified URL immediately.

In summary, the code handles retrieving a row from a HubDB table based on a query parameter if it exists. If the query parameter is not provided and the request is not from an in-page editor, it redirects the user to another URL.