0

I am Developing a React application with api calls to a laravel api. I uploaded the build folder after running "npm run buil" in the root of the website. I have then created a /api folder and uploaded the laravel project there. I created a database and imported the Database structure after running the laravel migrations. then in the htaccess file I wanted to redirect calls to the clientside to /index.html and calls to the /api folder to /api/public/index.php

I was looking at this post forthe htaccess file but it still does not work.

htacces file in public_html:

#redirect http to https
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.beyondthepack.com/$1 [R,L]


RewriteEngine on
#redirect /api calls
RewriteCond %{REQUEST_URI} ^/api/
RewriteRule (.*) /api/public/index.php [L]

#redirect al other calls
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]


what I want to do is redirect all request to index.html EXCEPT the requests to the api folder. the code I have does not work, what happen is:

  • all requests to the root and sub folders work fine
  • all of the requests to the /api folder fail with error code 500.

this is the header

in the server error log i do not see anything (I am using bluehost).

I am also having problem with CORS origin and I am ignoring it with a firefox plug in temporarily so that I can fix this problem first and then allow CORS in the .htaccess (I wasn't successful at that).

I do believe it is likely that the problem is in the htaccess files.

This is my first time deploying an app and I am not sure where the problem is.

Malkhazi Dartsmelidze
  • 4,783
  • 4
  • 16
  • 40
pietro
  • 1
  • 1
  • What does "does not work" mean _exactly_ ? Is not redirection performed at all? Does something work, other stuff not? What result do you get for requests? How did you enable to interpretation of distributed configuration files (".htaccess")? How did you check if that file gets considered? What does your http server's error log file contain? – arkascha Mar 15 '20 at 16:53
  • I added some more info. – pietro Mar 16 '20 at 18:43

0 Answers0