diff --git a/README.md b/README.md index 00f161a..e307540 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ -# angular-cli-redirect-script -server config for angular url to work directly in browser +# Angular-cli-redirect-script + +Server configuration file to add to your project for URL rewrite to work fine in production + +# How to use + +- copy the file depending on your platform to the source root directory of your project (`/src/`) + * `.htaccess` for apache + * `web.config` for IIS +- open the file `angular.json` or `angular-cli.json` depending on the angular version (should be at the root of your project) +- add the script to the build assets like the favicon `favicon.ico` or the `assets` directory + +For apache : + +```json +"assets": [ + "src/favicon.ico", + "src/assets", + "src/.htaccess" +] +``` + +For IIS : + +```json +"assets": [ + "src/favicon.ico", + "src/assets", + "src/web.config" +] +``` \ No newline at end of file diff --git a/apache/.htaccess b/apache/.htaccess new file mode 100644 index 0000000..174cfa5 --- /dev/null +++ b/apache/.htaccess @@ -0,0 +1,7 @@ +RewriteEngine On + # If an existing asset or directory is requested go to it as it is + RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] + RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d + RewriteRule ^ - [L] + # If the requested resource doesn't exist, use index.html +RewriteRule ^ /index.html \ No newline at end of file diff --git a/iis/web.config b/iis/web.config new file mode 100644 index 0000000..9eaeac6 --- /dev/null +++ b/iis/web.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file