*

Lucky

  • ***
  • 69 posts
How to rewrite the Canonical link?
« on: September 22, 2026, 06:54:16 PM »
Hi!

I'm using:
- Osclass v8.4.0 (recently upgraded from v8.3.0)
- Epsilon Osclass Theme v1.7.5
- Age Warning Plugin v1.3.0
- All in One SEO Plugin v3.4.1

When I check my code it shows:
<link rel="canonical" href="https://mysite.com/">

When I make an SEO analysis, it says my canonical URL points to the age-warning page, not the homepage:
<link rel="canonical" href="https://mysite.com/index.php?file=agewarning%2Fwarning.php&page=custom">
and this is a critical issue according to the SEO analysis report.

How can I change it so it shows:
<link rel="canonical" href="https://mysite.com/">
while keeping the Age Warning Plugin active?

Can I make the change in the All in One SEO Plugin?

Regards,

Lucky
« Last Edit: October 30, 2026, 09:41:00 AM by Lucky »

*

Masaqa

  • *
  • 4 posts
Re: How to rewrite the Caninocal link?
« Reply #1 on: September 23, 2026, 03:07:21 AM »
Step 1: Check All in One SEO Plugin Settings
Most SEO plugins in Osclass have an option to automatically generate canonical URLs or handle custom pages.

Log in to your Osclass Admin Panel.

Navigate to Plugins or Settings related to All in One SEO.

Look for options regarding Canonical URLs. If there is an option to disable auto-generation for custom or plugin-intercepted pages, turn it on.

Step 2: Fix the Canonical Tag via Theme Header (header.php)
If the SEO plugin doesn't have an override setting, you can intercept the canonical generation in your Epsilon theme's header file. You want to explicitly tell Osclass that if the current page is the age warning page, the canonical tag should point back to the homepage

Access your server via FTP or File Manager and go to:
oc-content/themes/your theme/header.php (or wherever your theme's header file is located).

Look for where the canonical link is currently being printed (it usually looks like <link rel="canonical" href="..." /> or is handled by a hook like oc_run_hook('header')).

Wrap or replace the canonical generation with conditional logic. For example:

PHP
<?php
// Check if the current view is the Age Warning plugin page
$file = Params::getParam('file');
$page = Params::getParam('page');

if ($file == 'agewarning/warning.php' || $page == 'custom') {
    // Force canonical to point to the clean homepage
    echo '<link rel="canonical" href="' . osc_base_url() . '" />' . PHP_EOL;
} else {
    // Let Osclass / SEO plugin handle it normally for other pages
    // (If your SEO plugin uses a specific function, keep it here, otherwise use default Osclass canonical if available)
    if (function_exists('seo_canonical_url')) {
        seo_canonical_url();
    } else {
        echo '<link rel="canonical" href="' . osc_current_url() . '" />' . PHP_EOL;
    }
}
?>
Step 3: Verify the Fix
Clear your browser cache and any caching plugins you have active on Osclass.

Visit your website in an incognito/private window (where your age verification cookie isn't set yet so the warning page triggers).

Right-click, select View Page Source, and check the <head> section to confirm it now shows:
<link rel="canonical" href="your homepage link">

Verification Success: You will know this is fixed when your SEO analysis tool no longer flags the age-warning URL as the canonical tag for your homepage.

*

MB Themes

Re: How to rewrite the Caninocal link?
« Reply #2 on: September 25, 2026, 09:59:43 AM »
In 8.3.1 set of filters is available to do so withou core changes  ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Lucky

  • ***
  • 69 posts
Re: How to rewrite the Caninocal link?
« Reply #3 on: October 29, 2026, 04:24:07 PM »
In 8.3.1 set of filters is available to do so withou core changes  ;)
@MB Themes Can you tell me where I can find these filters in 8.4.0?

Thanks.
« Last Edit: October 30, 2026, 09:42:03 AM by Lucky »

*

MB Themes

Re: How to rewrite the Canonical link?
« Reply #4 on: October 30, 2026, 09:46:12 AM »
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Lucky

  • ***
  • 69 posts
Re: How to rewrite the Canonical link?
« Reply #5 on: October 30, 2026, 10:20:59 AM »
Here it is:
https://docs.osclass-classifieds.com/filters-i119
@MB Themes So in your very short answer you mean I need to add this line:

osc_add_filter('canonical_url', 'https://mysite.com/');

to functions.php?

Then I have 2 questions:

1. Which functions.php file? The one in my theme, oc-content/themes/epsilon/functions.php, or another one?

2. Can I replace 'https://mysite.com/' with a variable for my homepage or will that variable also contain the additional 'index.php?file=agewarning%2Fwarning.php&page=custom'? If so, what's the variable name for my homepage?

Thanks.

*

MB Themes

Re: How to rewrite the Canonical link?
« Reply #6 on: October 30, 2026, 03:33:15 PM »
not really, check few examples about filters, you can condition it and fine-tune.
'index.php?file=agewarning%2Fwarning.php&page=custom' is plugin ajax call
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots