서버 등 운영체제(OS)/Linux
How to setup apache server for React route?
jihun202
2020. 5. 26. 12:04
반응형
리액트 빌드 후 아파치에 배포하고자 할 때.
빌드 디렉토리를 DocumentRoot 로만 잡았더니, sub path 일때 오류가 발생했다.
virtualhost 를 아래와 같이 설정하면 된다.
<VirtualHost *:8080>
ServerName example.com
DocumentRoot /var/www/httpd/example.com
<Directory "/var/www/httpd/example.com">
...
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]
</Directory>
</VirtualHost>
반응형