Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect all requests to index.html EXCEPT requests to the /api folder

I need to have Apache funnel all requests to the index.html file (excluding resource requests - js, css etc), but any requests into the /api folder need to be funnelled to the Laravel front controller: /api/public/index.php

Can anyone share their .htaccess knowledge with me to help accomplish this?

like image 305
daninthemix Avatar asked Oct 18 '25 18:10

daninthemix


1 Answers

OK, got my answer. This is how to do it:

1 - send any requests into the /api folder to the Laravel front controller.

2 - send any other files beside that to the index.html file.

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/api/
RewriteRule (.*) /api/public/index.php [L]

RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
like image 187
daninthemix Avatar answered Oct 20 '25 08:10

daninthemix