Isssue with redirection - Reg

Keywords: WordPress Multisite - AWS - How to - Other

Description:
Hi,
I want to redirect to a domain with rewriting www & HTTPS (forced).
I tried the ways in bitnami WP documentation
I followed method 2 in approach A for HTTPS (with server name variable), it works fine & https is forced but the issue is with rewriting www.
I tried editing the bitnami.conf >default virtual host with the given code but it does not hold good(may be the virtual host should not be placed within the block, it shows an error in bnsupport tool).
https://docs.bitnami.com/aws/infrastructure/lamp/administration/redirect-custom-domains/
Hope somebody can help me with this issue(i’m stuck here, for a long period of time)
1.Where to place the code in the file
2.the code includes dots ?
PS:
Not a techie, just a beginner. please help me in detail about how to place the editing of vhosts in bitnami.conf & there are no vhosts block for 443 in bitnami.conf
Thanks in Advance

Hi @dinesh,

Do you want to redirect just one domain or all domains to www and https? Editing the wordpress-vhost.conf and wordpress-https-vhost.conf files should be enough.

You do not need to include the docs, that’s just to mention that the file has more content.

Hi Jota,
Thanks for the reply,
I need the redirection for all the different domains (incl. various sub domains)
i have tried 2 Versions,
V1
I - Edited wordpress-vhost.conf with (vhost:80 Rewrite to force https)
II - Edited wordpress-https-vhost.conf (vhost:443 rewrite to www)
Removing all the edits done previously & restarted apache.
V2
with the same steps above. I’ve also edited bitnami.conf with https forcing.

The output for both the version is that the websiite is not https & www
its plainly http://example.com

It would really be helpful, if you can tell me exactly what to do for the requirement.(stepwise).

Hi @dinesh,

Did you include these lines in the conf files?

https://docs.bitnami.com/aws/apps/wordpress/administration/force-https-apache/#approach-a-bitnami-installations-using-system-packages

You will need to edit all the virtualhost you created in the Apache’s configuration and restart Apache after applying the changes.

HI,

bitnami.conf, bitnami-ssl.conf,All prefix-vhost.conf in vhosts directory (5 files in total) edited with the code using server name variable (for forcing https) and
As mentioned yesterday the www redirection is only added to the wordpress-https-vhost.conf (vhost443) & wordpress-vost.conf (vhost80)
The browser displays Err_too many redirects.
In whatever way the login url is entered this is preferred,
example.com —>https://www.example.com
No http version is needed.
hope you can help me with this

Also tried as per this heading,
Redirect custom domains to the Apache server (bitnami.com)
In which all conf files are https forced & just bitnami.conf is added with www. rewrite.(for both 80&443 vhosts within the vhost default block)

Please do clarify this case. i have two doubts,
1.the order in which the rewrite engines are being written (https forcing/www redirection)
2.can we write two rewrites under a single rewrite engine command.
you can atleast share me the exact heading in spport for this purpose & also mention what to do first - forcing https / www redirect.

Sorry for the above 2 responses,
I just worked my way & understood that forcing https require changes in all.conf files in bitnami & vhosts directory of apache.
The forcing works perfectly!
I also understand that for rewriting to www’s we have to edit the 2 files as you mentioned above (wordpress-vhost&https-vhost.conf).
Do clarify few tings for me - because we have already placed forcing code in those 2 files.

  1. Please state, the position of www rewrite w.r.t forcing code in the same block
    2.do i have to place both the codes (vhost 80&443) in both the pages or what…?

Hi @dinesh,

You only need to add the rules to the Virtualhost 80 directive in /opt/bitnami/apache2/conf/bitnami/bitnami.conf right after
DocumentRoot.

Regards,
Michiel

Hi,
In the said file, bitnami.conf; there is only a default vhost:80
can i add the the code as it is (or the & dots at the beginning & end are for denoting purposes only & not to be included in code).
as in this page,
[Redirect custom domains to the Apache server (bitnami.com)]
Also there is no block for 443 in the file
Do you want me to create a directory outside the 80’s closing of

Hi @dinesh,

You can just add the lines but without the dots, and only to the existing virtual host 80 directive.

Regards,
Michiel


This is the actual bitnami.conf file.
There could be any mistake(s), possibly - please point them & mention the remedies.
Current output: The Website refused to connect (after making changes & restarting apache, clearing browser cache).
Please I request you to offer some viable solution to this never ending issue!!!

Hi @dinesh,

You’ve added the virtualHost 443 directive inside the virtualHost 80 directive. This won’t work. You can find the original file in /opt/bitnami/bnsupport/original-data/apache2/conf/bitnami/bitnami.conf, please look at the original structure of the file, you will see that each virtualHost directive has opening and closing tags:

  <VirtualHost _default_:80>
    DocumentRoot "/opt/bitnami/apache2/htdocs"
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
    RewriteRule ^/(.*) https://example.com/$1 [R,L]
    ...
  </VirtualHost>

In /opt/bitnami/apache2/conf/bitnami/bitnami.conf you will find VirtualHost 80 and you need to add the same lines to the VirtualHost 443 directive in /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf

Best regards,
Michiel

I have edited as per your direction but the www prefixing is not carried out after forcing https.
please take a look at both the files & do share the review


PFA in next post (i cannot upload it in this post)

Additionally, please let me know the reason to place the www rewrite rule in http - vhost:80
my understanding is that the http is to be forced to https with www in front - prefixed. Correct me if i’'m wrong.

Hi @dinesh,

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

How to Run the Bitnami Support Tool in a cloud image or virtual machine

Please note that you need to paste the code ID that is shown at the end.

Regards,
Michiel

Hi,
This code is generated as per your instructions
Hope you can help me with this issue
2436edbc-8af9-8252-efe8-f6e41232ed8d

Hi @dinesh,

Why don’t you redirect to https://www directly:

<VirtualHost _default_:80>
   ...
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  ...
</VirtualHost _default_:80>

Please note that you also need to configure the WordPress domain as www.yourdomain.com:

https://docs.bitnami.com/ibm/apps/wordpress-multisite/configuration/configure-wordpress-multisite/

Regards,
Michiel

Hi,
The idea actually worked…!
Just removed the www, rewrite codes & reconfigured www.example.com as domain
But when i tested with the example.com (w/o www), it redirects to the wp-signup.php page (automatically).
Solution to this will complete the prevailing issue.

Hi @dinesh,

You need to configure WordPress with your own domain, which must be configured to have an A record pointing to your machine. Are you doing that?

Regards,
Michiel

Hi,
That setup was taken care of & the issue is also resolved by placing a noblog redirect in wpconfig.
But this setup will only work for the stipulated domain name (the www rewrite), which is OK for now. but please also enlighten me about the process for additional domains too.(since we have not used any rewrite rule. just changed the main domain name of the site with www).