mercredi 2 janvier 2019

How do I exclude /public and /api in .htaccess?

Since I'm using Laravel on a shared hosting service I need to have a redirect for the resources in the public folder.

I have this in my .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Rewrite everything to https
  RewriteCond %{HTTPS} !=on
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  RewriteCond %{REQUEST_URI} !^public
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

When I try to reach /api/login I get a 301 redirect to /public/api/login which then fails, since it doesn't exist.

How do I exclude both /public/* and /api/* from the public redirect rule?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire