Support » Fixing WordPress » Solution: HTTPS SSL certificate causing 404 error with custom permalinks

  • Resolved suprimax

    (@suprimax)



    Hi,

    since I struggled with this issue for a while, I think it would be helpful to share the solution with the community.

    What I have:
    Wordpress on Apache with WooCommerce running on Ubuntu (hosted by Linode).
    I bought PayPal Pro plugin to accept payments on my website.
    Bought SSL certificate from Comodo and activated it (let me know if you need the steps, but it involves running openssl command and copying bunch of certificates) to files. At the end I had default-ssl file in available-sites directory that pointed to my private key, public certificate from SSL company and some intermediate file.
    To enable the SSL I had to run “sudo a2ensite default-ssl” and confirmed that SSL was working by going to https://<my websites> that prompts a message “It works!”.

    When I forced SSL on checkout pages through WooCommerce configuration – I start receiving error 404 (page not found) on these pages.

    After quick research I found that there are many posts that indicate “pretty” links are not supported through SSL and the only way to make them work is to change permalinks to default and get this ugly ?page_id link.
    This solution was not acceptable for us as all product pages are already hard linked by 3-rd party websites and loosing all these goodies just for the sake of ssl did not make sense.
    So, I made executive decision to keep custom permalinks. Finally came across article that suggested to modify default-ssl file and add the same directives that make permalink work in htaccess file.

    Here is content of my default-ssl file. Please substitute ip address and directory with values applicable to your environment.
    <VirtualHost _default_:443>
    ServerName <ipaddress>:443
    ServerAdmin webmaster@localhost

    DocumentRoot /home/webadmin/public/<website>/public/
    <Directory /home/webadmin/public/<website>/public/ >
    AllowOverride All
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    </Directory>

    …. other SSL stuff ….

    Lat command:
    /etc/init.d/apache2 reload

    and I got my https properly showing the webpages with https and custom permalinks.

    Hope this helps!

    Max

Viewing 5 replies - 1 through 5 (of 5 total)
  • Max, you just saved me untold hours of pain and suffering. Thanks for posting this, just what I needed,

    Star! You’re amazing! I NEVER would have figured this out on my own, and figuring the frequency of mod_rewrite with WordPress and SSL, I’m surprised nobody else had.

    Max, thank you!

    Thank you so much 🙂

    johnnyBash

    (@johnnybash)

    Which part is .htaccess and which part goes in default-ssl?
    Is it possible to access this stuff on a shared hosting server, just through cPanel or FTP? Or do you need to do all that ugly SSH stuff?

    suprimax

    (@suprimax)

    Everything goes to default-ssl.

    The .htaccess contains regular wordpress stuff:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    I am not sure about shared environment – I use the virtual private server where I have full access to all files.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Solution: HTTPS SSL certificate causing 404 error with custom permalinks’ is closed to new replies.