Here I log the htaccess redirect code I use for the sites that I manage. Put the code in the top of the htaccess file. For some of the below codes the sub folder URL redirects did not work correct when the code was after the Joomla default htaccess entries.

To redirect all pages from www to non-www domains.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]

To redirect all pages from non-www to www domain.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

To redirect all http to https.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

To redirect a domain to a different domain. Both the www and non-www variant of the domain are redirected.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?$
RewriteRule ^(.*)$$1 [L,R]

To redirect a single file to a new URL.

Redirect "/location/of/file.mp4"

Hope this helps

Cookie policy

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Cookie Policy