Apache httpd.conf for redirecting ip to hostname

后端 未结 6 1966
执念已碎
执念已碎 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条回答
  •  轮回少年
    2020-12-25 15:03

    This works for me. Add the configurations in httpd.conf of apache

    CASE-1: when user hits http://XX.XX.XX.XX/main or http://ayz-abc.mysite.com/main it should be redirected to https://ayz-abc.mysite.com/main

    Configuration:

    #
    # Use name-based virtual hosting.
    #
    NameVirtualHost *:80
    
    ServerName XX.XX.XX.XX
    Redirect /main https://ayz-abc.mysite.com/main
    
    

    CASE 2 : When user hits https://XX.XX.XX.XX/main it should be redirected to https://ayz-abc.mysite.com/main

    Configuration:

    NameVirtualHost *:443
    
    DocumentRoot "/var/www/html"
    #Server Name 
    ServerName XX.XX.XX.XX
    SSLEngine on
    SSLOptions +StrictRequire
    # Redirect to the specified URL 
    Redirect /main https://ayz-abc.mysite.com/main
    
    SSLRequireSSL
    
    ....
    ....
    
    

提交回复
热议问题