HTACCESS file work on live server, but 500 server error on Local

Issue Summary

My .htaccess rules work fine on our live server, but I get a 500 server error on Local

Troubleshooting Questions

  • Haven’t tested on other sites, but I suspect it would happen with all of them

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser?

Replication

  1. Spin up a WordPress website with local
  2. Migrate the site to a live web host
  3. Add the HTACCESS rules I have provided
  4. Observe that the SSL padlock shows up fine with no errors on the live site
  5. Observe the exact same HTACCESS rules causing “500 Internal Server Error” on Local
<IfModule ssl_module>
RewriteEngine On
RewriteCond %{HTTPS} !=on

Header always set Content-Security-Policy "upgrade-insecure-requests;"
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
</IfModule>

System Details

  • Which version of Local is being used?
    7.0.2+6395
  • Windows 10 64-bit
  • PHP: 8.1.9
  • Web Server: Apache 2.4.43
  • Database: MySQL 8.0.16

Security Reminder

Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Hi @CodeSlayer2010

When you add your rules are you restarting the site in Local? You’ll need to do that so it can compile the changes.

Keep us posted and we’d be happy to help further!

Hi @Nick-B

Yes. I don’t have a restart button in my Local so I’m doing “stop site” and “start site”. I have also tried completely exiting Local and then restarting the app and then starting the site, but to no avail. Is that what you mean?

image

image

If I’m spitballing, could it have something to do with DNS not refreshing? Is that controlled by Local? Is local really “local” or is it connecting to some API online?

Thanks

Hey @CodeSlayer2010

Just to clarify, was this working at any point previously and then stopped? Or was this your first time trying it?

I don’t know that I would call this solved, but here is the closure I can give to anyone who happens upon this post.

  • It may have had something to do with WordFence plugin blocking things it should be allowing
  • Ultimately, using the Redirection plugin solved the issue though it doesn’t explain the server errors

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.