Apache httpd.conf for redirecting ip to hostname

后端 未结 6 1971
执念已碎
执念已碎 2020-12-25 14:18

I have external IP and hostname configured for my machine.

Inside the application, I am using only the domain names to access the APIs. So when i try to access my AP

6条回答
  •  猫巷女王i
    2020-12-25 14:47

    If you are using https domain than add following:

    # BEGIN HTTPS Redirection Plugin
    
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^XX\.XX\.XX\.XX$
    RewriteRule ^(.*)$ https://your-domain-name.com/$1 [L,R=301]
    
    # END HTTPS Redirection Plugin
    

    We are using https redirection plugin on site. Above block of code is generated by the plugin and we added only two lines in the code block. Below two lines are responsible to set IP to Domain redirection:

    RewriteCond %{HTTP_HOST} ^XX\.XX\.XX\.XX$
    RewriteRule ^(.*)$ https://your-domain-name.com/$1 [L,R=301]
    

    Here ^XX.XX.XX.XX$ is your IP address, replace it like this: ^12.34.56.78$ with your server IP.

    Thanks

提交回复
热议问题