First, a warning. Adding redirections to the .htaccess file is a bad idea when you have more than a couple dozen. The reason is that the .htaccess file needs to be loaded and parsed for every single request, including PHP (Joomla, WordPress, …), CSS files, JavaScript files, images, videos, everything. When you approach 300 redirections even the fastest server will start showing a measurable page rendering delay which will have an adverse impact on your search engine rankings.
We strongly recommend that you use Admin Tools' URL Redirec feature instead. This only runs when Joomla is generating a page (typically, an HTML page), and they're typically much faster than parsing a .htaccess file.
Regarding the custom redirections, if you have them as RewriteRule files you can add them to the "Custom .htaccess rules at the top of the file" since you want them to take effect before any of the protection rules.
Another reason they might not work, is that the sample you provided is wrong. If they are all in this format, well, your site will break. Let's take a look:
RewriteRule ^/laser-beam-delivery.html $https://www.haaslti.com/products/beam-delivery [R=301,L]
The space should be after the $
, not before it. The structure you are trying to do is RewriteRule MatchRegex RedirectURL [FLAGS]
. When the URL path matches the regular expression MatchRegex Apache will redirect the user's browser to RedirectURL. The FLAGS you are using tell Apache to perform the redirect using the HTTP 301 status code (Moved Permanently), and stop processing other rules when this rule matches; the flags are correct.
The problem is your MatchRegex. The ^
matches “start of string” and the $
matches “end of string”. That's why you were trying to write ^/laser-beam-delivery.html$
without a space before the $
character. Further to that, this being a regular expression the dot (.
) has a special meaning: match any character. This rule is therefore also wrong because it would match laser-beam-delivery-html
which is not what you want. Instead, you need to “escape” the dot using \.
in its place.
The correct rule would be:
RewriteRule ^/laser-beam-delivery\.html$ https://www.haaslti.com/products/beam-delivery [R=301,L]
This means that you need to go through all your rules and check them one by one. If you are going into this trouble, why not transfer them into Admin Tools' URL Redirect feature? In any case, it's up to you. I have to give you both options, explain the pros and cons, and let you decide what works best for your use case.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!