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.

EA4 Migration Breaking htaccess Rewrite Rules?

Discussion in 'EasyApache' started by BillyS, Nov 13, 2016.

  1. BillyS

    BillyS Active Member

    Joined:
    Mar 22, 2013
    Messages:
    37
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    I'm not an expert in rewrite rules but on Saturday and Sunday I figured I'd give EA4 a try because I wanted to eventually move over to php 7.

    After migration on Saturday, I noticed at least one rewrite rule was not longer working and this forced me go back to EA3, which was smooth (thankfully). I tried again on Sunday morning, I figured I'd try to do some troubleshooting. The site is based on Joomla 3.6 series, I first noticed the problem when the URIs were no longer redirecting to lowercase:

    EA3 rule:
    Code:
    # To Lower case
    RewriteCond %{REQUEST_URI} [A-Z]
    RewriteRule (.*) ${lc:$1} [R=301,L]
    EA4 rule after migration:
    Code:
    # To Lower case
    RewriteCond %{REQUEST_URI} [A-Z]
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule (.*) ${lc:$1} [R=301,L]
    Here is a second example:
    EA3 Rule:
    Code:
    # Begin - Redirect non-www to www
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    EA4 rule after migration:
    Code:
    # Begin - Redirect non-www to www
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    Again, I'm no expert on rewrite rules. I wondered if somehow the .htaccess file got corrupted during the migration. Unfortunately, when I replaced the EA4file with a backup I had, the lowercase rule still didn't work. I wound up going back to EA3.
     
  2. BillyS

    BillyS Active Member

    Joined:
    Mar 22, 2013
    Messages:
    37
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Does EA4 play with the httpd.conf file too? Half of the lower case rules are in that file. The site broke during the upgrade, so I didn't want to spend an hour trying to troubleshoot the problem. I really don't understand why EA4 needs to adjust the .htaccess file. Seems like a recipe for broken sites.
     
  3. BillyS

    BillyS Active Member

    Joined:
    Mar 22, 2013
    Messages:
    37
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Should I just open a ticket on this one? I really don't feel like taking my site offline just to troubleshoot if someone can explain to me how to fix the broken rules.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

    The addition of the following lines in the .htaccess file is to ensure domain validation attempts from providers such as Comodo are not blocked during the AutoSSL generation attempt:

    Code:
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    
    However, this doesn't appear to be the cause of the problem you have reported, as you mentioned the issue persists when reverting to the previous rules.

    Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
  5. BillyS

    BillyS Active Member

    Joined:
    Mar 22, 2013
    Messages:
    37
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    I figured it out, so I'll post what happened in case someone else runs into this problem.

    I used the Include Editor to insert two lines that make this lower case work:

    RewriteEngine On
    RewriteMap lc int:tolower

    These were set up as a Post Virtual Host Include. Sure enough, after running the upgrade, those two line were gone. I put them back in, restarted Apache and everything seems to be working now.

    Without more testing, it seems like information placed in these Includes gets wiped out during the upgrade.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,285
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Did you have the Post VirtualHost Include field used for a specific Apache version, or was "All Versions" selected before the migration to EasyApache 4? Also, could you verify the version of cPanel installed on the system at the time of the upgrade to EasyApache 4?

    Thanks.
     
Loading...

Share This Page