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.

How to put RewriteRule create by Mime::add_redirect to top of .htaccess

Discussion in 'cPanel Developers' started by haulpd, Jul 27, 2017.

  1. haulpd

    haulpd Active Member

    Joined:
    May 20, 2011
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    58
    How to change position of RewriteRule in .htaccess

    I have call UAPI to redirect customer website if that matched my rules, but I have a problem that if in .htaccess my customer have rule with [L], my directive can not process.

    How can i change position of directive block created by Mime:add_redirect to top of .htaccess

    Thanks!
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,172
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you provide an example of what the .htaccess file looks like before adding the redirect?

    Thank you.
     
  3. haulpd

    haulpd Active Member

    Joined:
    May 20, 2011
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    58
    Yes, it like that, just default .htaccess of Wordpress
    do You have solution to add redirect rule to top of .htaccess or we need copy old .htaccess to .htaccess.current and write new .htaccess to hosting.

    Thanks!
    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,172
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    It's not possible to alter the position of the Mod_Rewrite rules added when setting up a new redirect through cPanel. You'd need to setup your custom script to add those custom rewrite rules back in the position you need them in. I encourage you to open a feature request if you'd like to see more functionality regarding how redirects are configured through cPanel:

    Submit A Feature Request

    Thank you.
     
  5. haulpd

    haulpd Active Member

    Joined:
    May 20, 2011
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    58
    Thank you Michael
     
    cPanelMichael likes this.
Loading...

Share This Page