I have a Joomla 3.9.13 site, using Gantry 5.4.31.

I have a limited number of articles I want to remove from my site, and instead of returning a 404 error I want to return a 410 error.

I am not a programmer so I need help in figuring out the correct syntax and location in the .htaccess file to enter the code.

The final name of the articles are like this, and there are 46 of them:


I would like to know the correct syntax for anything that includes these in them, and it could include additional text before, and additional text after, such as:




Also, I'd like to know how to tell it which page to deliver. Would it be the default error page? Or should I create some other page? Technically, the content of the visual 410 error page will be the same as my current error page. But I'm not sure how Joomla with Gantry constructs the error page. If it's easier, I'll just create a page to use. Either way, what is the syntax for the .htaccess page to tell it where to find the correct error page?

Below is my current .htaccess file, with some items removed I know aren't relevant:

# @package    Joomla
## No directory listings

<IfModule autoindex>
  IndexIgnore *

## Can be commented out if causes errors, see notes above.
Options +FollowSymlinks
Options -Indexes

## Mod_rewrite in use.

RewriteEngine On

## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site then comment out the operations listed 
# below by adding a # to the beginning of the line.
# This attempts to block the most common type of exploit `attempts` on Joomla!
# Block any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root home page
RewriteRule .* index.php [F]
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
## End - Custom redirects

# Uncomment the following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).

# RewriteBase /

## Begin - Joomla! core SEF Section.
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
## End - Joomla! core SEF Section.

<IfModule mod_expires.c>
  ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault "access plus 1 year"


AddOutputFilterByType DEFLATE font/woff2
# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  • 1
    /23-10003-10054-almonds - do the format of the URLs you want to remove differ from the other URLs? Or is there no discernible difference? eg. The URLs you've listed all start with 2 digits in the path segment. Are these 2 digits common for all URLs or unique to the ones you want to remove?
    – MrWhite
    Dec 19, 2019 at 10:15
  • 1
    No, all my articles have numbers at the start. There's no real pattern that makes them unique.
    – Thora
    Dec 20, 2019 at 15:36

1 Answer 1


You could create 46 rewrite rules like this. They would need to go into your .htaccess file before the ## Begin - Joomla! core SEF Section.

RewriteRule ^/?23-10003-10054-almonds - [G,L]
RewriteRule ^/?90-10310-10027-corn-starch - [G,L]
RewriteRule ^/?25-anticaking-agents - [G,L]
RewriteRule ^/?29-bulking-agents - [G,L]
  • ^ means that "starts with"
  • /? is an optional starting slash. This could be omitted in .htaccess. The starting slash needs to be on the rule in Apache .conf files and needs to be omitted in .htaccess. Making it optional with the question mark makes the rule more portable and able to be used in either place.
  • - means to leave the URL alone and not change it
  • G means "Gone" -- send the 410 status
  • L means "Last" -- so that no other rewrite rules are executed

These rules are going to execute for each and every request to your webserver. Having 46 of them is probably fine. If you were to expand to hundreds or rules, it could hurt performance.

You could also try combining them into one rule which might perform a bit better: RewriteRule ^/?((23-10003-10054-almonds)|(90-10310-10027-corn-starch)|(25-anticaking-agents)|(29-bulking-agents)) - [G,L] However, the rule would be very long and might be hard to maintain.

It doesn't look like Joomla supports sending a 410 status for removed articles out of the box. The Joomla Stack Exchange site has a couple questions about 410 codes:

However, neither of those exactly matches your situation. It might be worth asking there if there is a way to have Joomla return the 410 error rather than trying to do it in .htaccess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.