From 983db0972fe69625bd05e037a4aab7b25643eec1 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Sun, 5 Mar 2017 13:18:13 +0700 Subject: [PATCH 1/2] Add docs for apache's client side routing setting --- packages/react-scripts/template/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 3c95313946b..4627fdb8f5e 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1249,6 +1249,13 @@ This is because when there is a fresh page load for a `/todos/42`, the server lo res.sendFile(path.join(__dirname, './build', 'index.html')); }); ``` +If you're using [apache](https://httpd.apache.org/), you need to create a `.htaccess` file that is located beside your build's `index.html` that might look like this: +``` + Options -MultiViews + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.html [QSA,L] +``` Now requests to `/todos/42` will be handled correctly both in development and in production. From f9ec28e4fb86fbb165352c98ec8985c7b1c8dd4d Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sun, 5 Mar 2017 14:06:57 +0000 Subject: [PATCH 2/2] Tweak advice --- packages/react-scripts/template/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 4627fdb8f5e..4f48c05bda0 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1249,7 +1249,9 @@ This is because when there is a fresh page load for a `/todos/42`, the server lo res.sendFile(path.join(__dirname, './build', 'index.html')); }); ``` -If you're using [apache](https://httpd.apache.org/), you need to create a `.htaccess` file that is located beside your build's `index.html` that might look like this: + +If you’re using [Apache](https://httpd.apache.org/), you need to create a `.htaccess` file in the `public` folder that looks like this: + ``` Options -MultiViews RewriteEngine On @@ -1257,6 +1259,8 @@ If you're using [apache](https://httpd.apache.org/), you need to create a `.htac RewriteRule ^ index.html [QSA,L] ``` +It will get copied to the `build` folder when you run `npm run build`. + Now requests to `/todos/42` will be handled correctly both in development and in production. ### Building for Relative Paths