Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Redirect Through VirtualHost

Discussion in 'EasyApache' started by DHarry, Aug 3, 2017.

  1. DHarry

    DHarry Member

    Joined:
    Nov 9, 2016
    Messages:
    6
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Kansas City, Missouri
    cPanel Access Level:
    Root Administrator
    Hi and thank you in advance

    I've recently migrated to EasyApache 4 and I originally had a redirect via VirtualHost that no longer works.

    My Rewrite set up is as follows:
    Code:
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www.example.com%{REQUEST_URI}
    And this is inserted into an individual VirtualHost "without SSL" from the official documentation (Link: Modify Apache Virtual Hosts with Include Files - EasyApache 4 - cPanel Documentation)

    However, if I go to "example.com", it doesn't redirect to "www.example.com".

    I feel like everything I've done everything correctly but is there an additional change I need to make or am I overlooking something?

    I just cannot figure out why this no longer works.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,419
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Do you have any existing rewrite rules in the .htaccess file in the account's public_html directory? Also, could you verify the full steps you took to make the include file?

    Thank you.
     
  3. DHarry

    DHarry Member

    Joined:
    Nov 9, 2016
    Messages:
    6
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Kansas City, Missouri
    cPanel Access Level:
    Root Administrator
    Thanks!

    There is not a rewrite rule in the .htaccess file currently.

    For the steps, using the documentation, I created the includes file. The created path was for individual virtualhost, without ssl. Then I inserted the rewrite rule mentioned above in the .conf file. Rebuilt the httpd.conf file and restarted the Apache.

    Pretty simple, or so I thought.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,419
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You can try using one of the examples on the following post to see if it helps:

    HTTP to HTTPS redirects for Drupal Multisite Setup

    Additionally, run this command after making the change:

    Code:
    /usr/local/cpanel/scripts/ensure_vhost_includes --all-users
    
    Thank you.
     
  5. DHarry

    DHarry Member

    Joined:
    Nov 9, 2016
    Messages:
    6
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Kansas City, Missouri
    cPanel Access Level:
    Root Administrator
    Michael,

    Thank you so much for your help! I think the script was the missing piece I needed and everything is working accordingly.

    Have a great week and take care!
     
    cPanelMichael likes this.
Loading...

Share This Page