Non-www to www in Joomla

Keywords: Joomla - AWS - Technical issue - Other
bnsupport ID: Not available
Description:
Looked through different threads but one that has reference to further input does no point to actual resources.

I’ve added required code in .htaccess file and restarted apache also but this is not working - please note that correct domain name is included on lines also - without any typo.

## Mod_rewrite in use.

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


## 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.

Redirection is not working and so affecting crawling - what else is required for this Bitnami instance of Joomla so this redirection works?

Thanks.

Hi @cguanaja

You should not implement the redirection in the .htaccess file, but in the conf one. We have the process of redirecting custom domains (and even the non-www to www example) detailed in our guides, could you please take a look?

https://docs.bitnami.com/general/apps/joomla/administration/redirect-custom-domains/

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Thanks @jcarmona!

I’m following the guide provided and having an approach B installation with one question. It says that we “need to create new certificates for each virtual host running on port 443 or use existing certificates, such as the default certificates shipped with the stack.” On updating directives for option 1, there is no cert under the path specified.

bitnami@ip-172-26-5-193:/opt/bitnami/apps/joomla/conf/certs$ ls
bitnami@ip-172-26-5-193:/opt/bitnami/apps/joomla/conf/certs$ ls -la
total 8
drwxr-xr-x 2 bitnami root 4096 Jan 28 2020 .
drwxr-xr-x 4 bitnami root 4096 Jun 22 05:48 ..
bitnami@ip-172-26-5-193:/opt/bitnami/apps/joomla/conf/certs$

Can you please elaborate more on the need to create new certificates for each virtual host running on port 443 or using existing certificates?

Also - file /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf is empty - just add the one line that is required or is there anything missing on this empty file?

Thanks.

Hi again !

On updating directives for option 1, there is no cert under the path specified.

That is expected, as you are expected to create those certs or copy existing ones there.

Can you please elaborate more on the need to create new certificates for each virtual host running on port 443 or using existing certificates?

We have a guide that covers how to generate self-signed “dummy” certificates. Note that you may need to replace /opt/bitnami/apache2/conf/ by /opt/bitnami/apps/joomla/conf/certs in the guide :slightly_smiling_face:

https://docs.bitnami.com/google/apps/joomla/administration/create-ssl-certificate-apache/

Also - file /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf is empty - just add the one line that is required or is there anything missing on this empty file?

The file is empty as you are not using other vhosts. But yes, you are expected to add the line in that file.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Thanks @jcarmona

I’ve followed the guide and created both key and certificate but then payment of cert will be required - I already have a let’s encrypt cert for the site so not sure how this is related or can affect what is already in place with existing cert that is up and running for the site?

All I need is to remove duplicate content so redirecting non-www to www - any other guide that goes through this?

Thanks.

Lines above need to be added on htaccess.conf under /opt/bitnami/apps/joomla/conf

I added them on .htaccess under /opt/bitnami/apps/joomla/htdocs which is why this was not working.

All good now.

Glad to see you were able to solve your issue! We are marking the previous answer as “Solution” and this topic as “Closed”.

If you have any other questions, please do not hesitate to let us know. Feel free to create a new topic referencing this one if necessary.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

1 Like