How can I redirect my IP address to my domain?

Keywords: WordPress - AWS - How to - Domain Name (DNS)

Description:
I hosted my website on AWS and my website IP address is appearing in google search results which is kind of embarrassing for me. If people get the address somehow, I want them to automatically redirect to my domain. I have watched a lot of youtube tutorials and bitnami old topics as well but it didn’t solve my problem. Can someone help me regarding this issue?

Hi @ousodh

Thanks for using Bitnami WordPress!

We have a guide that covers this same topic :slightly_smiling_face:

https://docs.bitnami.com/aws/apps/wordpress/administration/use-single-domain/

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

No, it didn’t work for me. I changed the /opt/bitnami/apache2/conf/bitnami/bitnami.conf, /opt/bitnami/apache2/conf/vhosts/wordpress-vhost.conf and the /opt/bitnami/apache2/conf/bitnami/bitnami-ssl.conf file as well with the following config.

# BEGIN: IP TO OUSODH[.]COM
  <VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^3.108.167.36$
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ http://ousodh[.]com/$1 [R=permanent,L]
</VirtualHost>
# END: IP TO OUSODH[.]COM

# BEGIN: IP TO OUSODH.[]COM
  <VirtualHost *:443>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^3.108.167.36$
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ https://ousodh[.]com/$1 [R=permanent,L]
</VirtualHost>
# END: IP TO OUSODH[.]COM`

I want if people go to 3[.]108[.]167[.]36, they should automatically be redirected to ousodh[.]com! Please let me know what is wrong.

Why are you replying too slow? If you have no solutions, just let me know. I will install WordPress in an ubuntu instance.

Hi @ousodh

I want if people go to 3[.]108[.]167[.]36, they should automatically be redirected to ousodh[.]com! Please let me know what is wrong.

We would need to review your instance configuration to try to find out why the redirection is not happening. In order to review it, we need you to execute the bndiagnostic tool to analyze it. You can learn how to execute the tool here:

https://docs.bitnami.com/general/how-to/understand-bndiagnostic/

Once finished, the tool will provide an ID. Use this ID to create a new Technical Issue thread in the forum and one of your teammates will be more than happy to review it :slightly_smiling_face:

Why are you replying too slow? If you have no solutions, just let me know. I will install WordPress in an ubuntu instance.

Please note that we provide free support in this community forum to help our users with any questions they have. Due to our limited resources, and the high quantity of cases, we usually reply within a business day.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Nah, It didn’t work!

Hi @ousodh,

Thanks for getting back on this. Can you run the bndiagnostic tool as @jcarmona mentioned and share with us the new code? We would like to take a look at the updated configuration.

Apart from that, did you restart Apache for changes to take effect?

sudo /opt/bitnami/ctlscript.sh restart apache

I also visited your website using the curl tool and I have a question. When using the domain name, redirections work properly (it returns a 200 ok code)

$ curl -LI "http://ousodh.com"
HTTP/1.1 302 Found
Date: Tue, 21 Sep 2021 08:12:35 GMT
Server: Apache/2.4.48 (Unix) OpenSSL/1.1.1d
Location: https://ousodh.com/
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 301 Moved Permanently
Date: Tue, 21 Sep 2021 08:12:36 GMT
Server: Apache/2.4.48 (Unix) OpenSSL/1.1.1d
Location: https://www.ousodh.com/
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 200 OK
Date: Tue, 21 Sep 2021 08:12:37 GMT
Server: Apache/2.4.48 (Unix) OpenSSL/1.1.1d
X-Powered-By: PHP/7.4.22
cf-edge-cache: cache,platform=wordpress
Link: <https://www.ousodh.com/wp-json/>; rel="https://api.w.org/", <https://www.ousodh.com/wp-json/wp/v2/pages/17692>; rel="alternate"; type="application/json", <https://www.ousodh.com/>; rel=shortlink
Set-Cookie: digits_countrycode=880; expires=Fri, 24-Sep-2021 08:12:37 GMT; Max-Age=259200; path=/; secure; SameSite=None
Content-Type: text/html; charset=UTF-8

However, when visiting the IP address, the redirection fails because IP addresses can’t be secured with SSL certificates. Can you configure the redirect to the HTTPS website directly?

# BEGIN: IP TO OUSODH[.]COM
  <VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^3.108.167.36$
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ https://ousodh.com/$1 [R=permanent,L]
</VirtualHost>
# END: IP TO OUSODH[.]COM

The curl execution is shown below

curl -LI "http://3.108.167.36"
HTTP/1.1 301 Moved Permanently
Date: Tue, 21 Sep 2021 07:17:02 GMT
Server: Apache/2.4.48 (Unix) OpenSSL/1.1.1d
X-Powered-By: PHP/7.4.22
cf-edge-cache: cache,platform=wordpress
X-Redirect-By: WordPress
Set-Cookie: digits_countrycode=880; expires=Fri, 24-Sep-2021 07:17:02 GMT; Max-Age=259200; path=/; SameSite=None
Location: https://3.108.167.36/
Content-Type: text/html; charset=UTF-8

curl: (51) SSL: certificate subject name (ousodh.com) does not match target host name '3.108.167.36'

I configured the redirect directly to https like you said and restarted apache as well.

I also ran the bndiagnostic tool and the latest code is below-

`[Apache]

Found recent error or warning messages in the Apache error log.
```
[Tue Sep 21 12:11:27.065961 2021] [proxy_fcgi:error] [pid 29122:tid
139895917856512] [client **ip_address**:59252] AH01071: Got error 'PHP message:
WordPress database error Table 'bitnami_wordpress.ahc_search_engine_crawlers'
doesn't exist for query SELECT `bot_name` FROM `ahc_search_engine_crawlers` made
by do_action('wp_ajax_nopriv_ahcfree_track_visitor'), WP_Hook->do_action,
WP_Hook->apply_filters, ahcfree_track_visitor, ahcfree_is_search_engine_botPHP


[Resources]

Your instance has little available RAM memory.
```
 total used free shared buff/cache available Mem: 987 556 75 67 356 190 Swap:
634 150 484
```
You could try to increase your instance's memory. Please check your cloud
provider's documentation for more information.`

I hope you will be able to find a solution for this issue!

Hi @ousodh,

Thanks for your message. Unfortunately, that’s not the code we need to check your issues, it is a random code generated shown at the end of the process, once the file has been uploaded to our servers.

However, we recommend you to check the suggested guides in order to fix the issues that the tool found.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.