How to setup apache server for React route?

前端 未结 9 1093
无人共我
无人共我 2020-12-08 10:04

I have my react app running great on my local dev server but it did not work when I dump my production ready files straight into Apache\'s htdocs directory:

Here is

9条回答
  •  悲哀的现实
    2020-12-08 10:55

    Go on this directory

    1. /etc/apache2/sites-available

    2. open File : 000-default.conf

    3. Change its permission : 777

    4. Paste code on bottom of file

    RewriteEngine on 
    
    # Don't rewrite files or directories 
    
    RewriteCond %{REQUEST_FILENAME} -f [OR] 
    
    RewriteCond %{REQUEST_FILENAME} -d 
    
    RewriteRule ^ - [L] 
    
    # Rewrite everything else to index.html to allow html5 state links 
    
    RewriteRule ^ index.html [L] 
    

    1. Restart server

提交回复
热议问题