Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

.htaccess problems after enabling SSL [SOLVED]

edited May 2019 in Vanilla 2.0 - 2.8

I recently installed a fresh version of Vanilla 2.8.3 on a Linux host. Totally configured the site, all working perfectly. When I originally installed, I said "use Vanilla's .htaccess" because I didn't have any custom one on my site till that point.

Earlier today, I had to modify the .htaccess file at my web root, to redirect all http requests to https, as I now have access to an SSL certificate with my new hosting environment.

Now when I navigate to , I get http Error 500, "This page isn't working."

I tried appending the contents of the .htaccess file in the /forum folder to the bottom of the one at my web root, but that broke the forum AND my site! How do I best address this?

Thanks in advance....


  • charrondevcharrondev Developer Lead (PHP, JS) Montreal Vanilla Staff

    Could you share your current .htaccess file?

  • Thanks and sure. Here's what's in the .htaccess file at the root of my public_html folder:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} mysite\.com [NC]
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$$1 [R,L]
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$$1 [R=301,L]
    RewriteOptions inherit
    RewriteEngine on
    Header set content-Security-Policy: upgrade-insecure-requests

    The .htaccess file in my Vanilla root at /forum is the unmodified original one I believe:

    # Original
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
        RewriteEngine On
        # Certain hosts may require the following line.
        # If vanilla is in a subfolder then you need to specify it after the /.
        # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
        #RewriteBase /
        # Make sure that / doesn't try to go to index.php without a rewrite :)
        DirectoryIndex disabled
        # Deny access to certain directories that SHOULD NOT be exposed.
        RewriteRule (^|/)\.git - [L,R=403]
        RewriteRule ^cache/ - [L,R=403]
        RewriteRule ^cgi-bin/ - [L,R=403]
        RewriteRule ^uploads/import/ - [L,R=403]
        RewriteRule ^vendor/ - [L,R=403]
        # Prevent access to any php script by redirecting the request to /index.php
        # You can add an exception by adding another RewriteCond after this one.
        # Example: RewriteCond %{REQUEST_URI} !^/yourscriptname.php$
        # You can comment out this section if it causes you problems.
        # This is just a nice to have for security purposes.
        RewriteCond %{REQUEST_URI} !/index.php$
        RewriteRule (.+\.php) [E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]
        # Redirect any non existing file/directory to /index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule (.*) index.php [E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]
        # Add the proper X_REWRITE server variable for rewritten requests.
        RewriteCond %{ENV:REDIRECT_X_REWRITE} .+
        RewriteCond %{ENV:REDIRECT_X_PATH_INFO} (.+)
        RewriteRule ^index\.php - [E=X_REWRITE:1,E=!REDIRECT_X_REWRITE,E=X_PATH_INFO:%1,E=!REDIRECT_X_PATH_INFO,L]
    <IfModule mod_headers.c>
       <FilesMatch "(?<!embed)\.(css|js|woff|ttf|eot|svg|png|gif|jpeg|jpg|ico|swf)$">
          Header set Cache-Control "max-age=315360000"
          Header set Expires "31 December 2037 23:59:59 GMT"

  • Actually, I think I had extra, redundant stuff in the .htaccess file at the root of my public_html folder. Here's what it is now:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$$1 [R=301,L]

  • Following up on my own - this is now SOLVED, and was self-inflicted.

    I had inadvertently blown away the contents of the .htaccess file that specified that PHP 7.1 should be used on the site; therefore, PHP had reverted to v5.4 or similar. As soon as I replaced the code that ensures that 7.1 is used, everything started working normally again.

    Sorry for the noise!

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP

    Thanks for posting the resolution.

Sign In or Register to comment.