Support » Plugin: Multiple Domain » 302 Redirect

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Author Gustavo Straube

    (@gustavostraube)

    Hello,

    I couldn’t reproduce the redirect you mentioned. Accessing that URL gives me a 200 status code, check this out: https://imgur.com/a/LIvNrEC.

    Gustavo

    Hey @gustavostraube, thanks for a prompt reply… the issue is when you click any article on that url, it just reloads the page instead of going to that particular article

    Please let me know if this makes sense. Thanks

    Plugin Author Gustavo Straube

    (@gustavostraube)

    Yea, I’m sorry! I now see the issue. I guess you set the base path of dailymaverick.co.uk to /section/declassified-uk/. Am I right? If so, that’s causing the redirect.

    When setting a base path, only URLs under that path will be available. Otherwise, they’ll redirect to the base path. Since article URLs start with /article/, they don’t work. You have to omit the base path to get it working.

    Yes, these are my settings https://imgur.com/IrrsFoT please advice, how else can i can i do this?!

    Thanks

    Plugin Author Gustavo Straube

    (@gustavostraube)

    If you simply want to redirect the home page to /section/declassified-uk/, you could add the following to your theme’s functions.php file:

    function force_section_redirect() {
        if (is_home() || is_front_page()) {
            wp_redirect(home_url('/section/declassified-uk/'));
            exit;
        }
    }
    
    add_action('template_redirect', 'force_section_redirect');

    Also, leave the base path in the plugin settings empty.

    Let me know how it goes.

    • This reply was modified 6 days, 13 hours ago by Gustavo Straube. Reason: Fixed code
    Plugin Author Gustavo Straube

    (@gustavostraube)

    The snippet above was updated. I forgot to add it to inside an action.

    I don’t think that’s gonna work cause… the main site is https://dailymaverick.co.za/ and we using the plugin to go to https://dailymaverick.co.uk/sections/declassified-uk/ we using both sites, wont the above snippet redirect https://dailymaverick.co.za/ to /section/declassified-uk/ ? keep in mind the .co.za and .co.uk

    Plugin Author Gustavo Straube

    (@gustavostraube)

    Got you. Try this instead:

    function force_section_redirect() {
        if (MULTIPLE_DOMAIN_DOMAIN === 'dailymaverick.co.uk' && (is_home() || is_front_page())) {
            wp_redirect(home_url('/section/declassified-uk/'));
            exit;
        }
    }
    
    add_action('template_redirect', 'force_section_redirect');

    This way, it’ll only redirect when on dailymaverick.co.uk.

    Hey @gustavostraube i’m afraid that didn’t work… it’s still redirecting to the same page 🙁

    Plugin Author Gustavo Straube

    (@gustavostraube)

    I’ve just checked the order WordPress fires the hooks (actions and filters) and it seems the action I suggested (template_redirect) fires after init, which is used by the plugin. I hope the following will finally work as a replacement for the add_action call in the previous snippet.

    add_action('init', 'force_section_redirect', 1);

    I’m sorry for this game of trial and error.

    No its ok man i understand, i appreciate all your help… i’m afraid that didn’t work also though

    function force_section_redirect() {
        if (MULTIPLE_DOMAIN_DOMAIN === 'dailymaverick.co.uk' && (is_home() || is_front_page())) {
            wp_redirect(home_url('/section/declassified-uk/'));
            exit;
        }
    }
    add_action('init', 'force_section_redirect', 1);
    Plugin Author Gustavo Straube

    (@gustavostraube)

    Have you removed the base path from the plugin settings? I mean, set the field blank and save.

    No, i still have the old settings i sent you earlier… should i remove the base path?

    Plugin Author Gustavo Straube

    (@gustavostraube)

    Yes, please.

    I removed that base path, it’s still just reloading the page…

Viewing 15 replies - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.