Automatic 301 redirect for unpublished category articles

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
GillianBPP
Joomla! Explorer
Joomla! Explorer
Posts: 395
Joined: Wed Oct 01, 2014 10:25 am

Automatic 301 redirect for unpublished category articles

Post by GillianBPP » Thu Nov 23, 2017 4:28 pm

I manage the backend of a church website where the weekly notes are on view on a category blog page for four weeks, after which they are unpublished and expired.

This means that anyone trying to access an old article will instead get a 404 page returned unless I go on the website every week and set up a redirect for each article, which I really don't want to have to do.

Is there a way to tell Joomla that when an article is unpublished from category A that a 301 redirect can be set up automatically to a specific menu item A and if an article with category B is unpublished a 301 redirect is set up to menu item B, etc?

Could it be done in .htaccess for expired articles in a specific category but without redirected published articles?

Thanks for any suggestions.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44051
Joined: Sat Apr 05, 2008 9:58 pm

Re: Automatic 301 redirect for unpublished category articles

Post by Webdongle » Thu Nov 23, 2017 7:29 pm

How are they trying to access an unpublished Article ? Perhaps it might be easier to rethink your navigation ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Automatic 301 redirect for unpublished category articles

Post by sozzled » Thu Nov 23, 2017 8:06 pm

@Webdongle: people are probably locating these unpublished articles because they've found them via some search engine result; just guessing.
Scrabble wrote:[Articles are displayed] on a category blog page for four weeks, after which they are unpublished and expired. This means that anyone trying to access an old article will instead get a 404 [response].
Yes, that's standard, normal behaviour for any website. Changing the behaviour from HTTP 404 Page Not Found to HTTP 301 Moved Permanently is probably just as "unsatisfying" (from the end user's perspective); I mean, from the end user's perspective, they find a search result, they go to a wesbite and they get slapped around in their face with "bad luck, chum, but you can't get that page any more."

Although there are technical issues involved in resolving this issue—on that matter I can see why this topic fits the "J! 3.x Administration" forum category—this is also as much about SEO and how SERPs play out with people who use search engines.

Thinking out aloud on this matter, one way to achieve the end result might be to write a Joomla content plugin that selected articles in a certain category, and changed the header (a bit like this):

Code: Select all

<?php
header(“HTTP/1.1 301 Moved Permanently”);
header("Location: http://yourwebsite.com/your-web-page");
exit();
?>
Another way to avoid slapping the "congregation" in the face with "tactless" HTTP errors would be to take down (remove) the SERP results from the search engine.

I don't have many other suggestions. My personal feeling is that if I go to a website and I get either a 404 or a 301, after spending my time using Google to get to that place, I tend to stop visiting the website, anyway.

GillianBPP
Joomla! Explorer
Joomla! Explorer
Posts: 395
Joined: Wed Oct 01, 2014 10:25 am

Re: Automatic 301 redirect for unpublished category articles

Post by GillianBPP » Fri Nov 24, 2017 6:53 pm

Thanks, Sozzled.

One reason that visitors are finding old articles - which in this case really is old news - could be that if you start typing an address in the URL bar it comes up with historical urls to choose from.

Anyway, to explain why unpublishing an article is not really a slap in the face in the context of this website, on another page, we have 'services this month and next' as a category blog. Only two articles are displayed in two columns, and the oldest published one is displayed first, on the left. So, as I write on 24th November, it displays articles 'November' and 'December'. At 00:01 on 1st December, the November one is unpublished, December moves over to the left-hand side (or top on a mobile or tablet) and January 2018 appears on the right-hand side, (or bottom).

Now, if I didn't unpublish the November article, the January one would never appear and I can't see any other way to achieve this without changing the display order manually on the first of each month, and I certainly don't want to be doing that.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44051
Joined: Sat Apr 05, 2008 9:58 pm

Re: Automatic 301 redirect for unpublished category articles

Post by Webdongle » Fri Nov 24, 2017 7:12 pm

Category can be ordered by Article reverse order


You can create a hidden menu item to an Article for your 404 page then define it as the 404 page in .htaccess
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30863
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Automatic 301 redirect for unpublished category articles

Post by Per Yngve Berg » Fri Nov 24, 2017 7:24 pm


sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Automatic 301 redirect for unpublished category articles

Post by sozzled » Fri Nov 24, 2017 7:30 pm

Scrabble wrote:One reason that visitors are finding old articles - which in this case really is old news - could be that if you start typing an address in the URL bar it comes up with historical urls to choose from.
Although there could be many ways that "visitors" to your website may be discovering outdated URLs, the situation you describe would only apply to regular visitors (or perhaps site managers). I'm not disputing the reasons why you may want to archive or unpublish yesterday's news but I am asking you to question the difference between sending people an abrupt HTTP response code (either a 404 or a 301) and providing a softer message like "The page you've requested was removed from the website because it was over a month old and we don't keep old articles on this website."

I understand that some site managers only want to display current news information for a short time. What I'm challenging is how to cater to site visitors who stumble on a URL—however they may stumble upon those URLs whether via a search engine or by autocompleting a URL stored in the browser's history—in a way that's meaningful. As I mentioned in my previous message, there are technical mechanisms available to change a 404 to a 301 (if that's what you want to do) but, in reality, what's the difference from the end user perspective?

Is it worth the investment of your time to change 404s to 301s and, when people encounter these things, what are they likely to do as a consequence? I think that's the real question.

@Webdongle's suggestion, to order the articles in reverse chronological sequence may be worth looking at.

The simple fact, however, is that when an article is created with a start/end publishing date, after the publishing period expires these articles will no longer be reachable. The standard response code is HTTP 404 Page Not Found. You could create a custom HTTP 404 page to provide additional information such as ""The page you've requested was was not found or may have been removed from the website because of our publishing policy" (or words to a similar effect). :)

Another way to resolve the issue is to use the Joomla Redirection Manager (component and plugin) so that, after people hit the 404 situation (and the plugin detects it) you define a case-by-case redirection in the component to redirect the visitor to one (or more) specific URL(s) as you asked in your original question. A little bit of an overhead but not much, I suspect.

GillianBPP
Joomla! Explorer
Joomla! Explorer
Posts: 395
Joined: Wed Oct 01, 2014 10:25 am

Re: Automatic 301 redirect for unpublished category articles

Post by GillianBPP » Sat Nov 25, 2017 1:06 pm

Thank you, Sozzled and Webdongle, for your comments and suggestions.

I do, in fact, have custom 404 pages on all my sites, so it's not quite so abrupt as the default system 404 landing page.

I have been using the Joomla built-in Redirects component with the plugin set to collect URLs. But that takes me back to my original comment that I really don't want to spend my time on clients' websites setting up 301 redirects every time an article - which I usually haven't created in the first place, so I don't know when they are due to be unpublished - is unpublished.

Most of my clients don't have back-end administrator access as they do not have the technical know-how to be given access. They are churchwardens, village hall treasurers, restaurant owners and the like; certainly not website administrators.

I guess it's a bit of a catch 22 in this case :-(

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30863
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Automatic 301 redirect for unpublished category articles

Post by Per Yngve Berg » Sat Nov 25, 2017 1:32 pm

You can add a link on the Custom 404 Page that will take the visitor to the category.


Locked

Return to “Administration Joomla! 3.x”