0

Typically I make a website with reactjs + node + express, which is the usual combination. Then I deploy to Heroku and all is well.

However, at request I have done reactjs front end with php back end deploying to cpanel and have run into the 404 issue with client side routing - if navigating directly to non-home-page route (let's say domain/quote) there is nothing on the server with that url and 404 error is thrown.

I found the principle of the solution here but this and all other answers I've found refer to node+express back ends only.

Any way this can be done with a straight php back end? I am not using laravel or another framework.

Also, though I have learned a lot recently I still consider myself a beginner - my apologies if the answer ends up being somewhat obvious.

  • Update: My public_html in cpanel didn't have .htaccess file so I created and tried to get 404 error to redirect to index.html so it's always served - this has not worked so far. – washboardalex Nov 18 '18 at 10:59

1 Answers1

0

Ok, fellow php back end users, I did find a solution and it is in the .htaccess file.

Add it to public_html in cpanel and set permissions to 755 or to execute.

More information here.