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!

htaccess redirect assistance

Discussion in 'General Discussion' started by gold123456, Jun 12, 2018.

  1. gold123456

    gold123456 Registered

    Joined:
    Jun 12, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    london
    cPanel Access Level:
    Root Administrator
    Dear all,

    I am a developer and have an account set up on cPanel.

    I have 2 environments, a demo subdomain, and the main domain for production.

    So example; demo.example.com -> /home/demo/ (outside public_html)
    and movies.com -> public_html

    I have the following htaccess file:

    Code:
    RewriteEngine on
    
    <IfModule mod_rewrite.c>
        RewriteEngine on
        # let the PHP knows that the mod_rewrite module is ENABLED.
        RewriteCond %{HTTPS} off
        RewriteRule (.*) [URL]https://%[/URL]{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>
    
    The purpose of this thread is to seek help. I want to be able to redirect all http requests to https.

    On the same server their is another account which handles rewriting URLs. This makes me believe mod_rewrite is working as expected.

    Can someone help me please? I want to be able to redirect:

    Code:
    http://demo.example.com
    to
    Code:
    https://demo.example.com
    Code:
    http://movies.com
    to
    Code:
    https://example.com
    or
    Code:
    https://www.example.com
     
    #1 gold123456, Jun 12, 2018
    Last edited by a moderator: Jun 12, 2018
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,888
    Likes Received:
    90
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,

    The code you gave may work as expected, but the thing is there are lot of such codes available and it differs slightly from CMS to CMS, like for wordpress some of these codes work and the same does not work as expected for Joomla site. You will have to check what best suits your website requirement. You can also use some plugins for your CMS if you are using one and then check..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,442
    Likes Received:
    1,961
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice