ng build
does not copy .htaccess
to dest
dir. I have tried to put .htaccess
in both src
and src/assets
folder but in both cases .htaccess
does not appears in dist
folder.
Here are more details about:
Linux Mint 18.1 “Serena”
angular-cli: 1.0.0-beta.28.3
node: 7.5.0
os: linux x64
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/compiler-cli: 2.4.7
ng new angular-cli-test
cp kibernum-dnc-client/src/.htaccess angular-cli-test/src/
cd angular-cli-testng build
ls -la dist/mv src/.htaccess src/assets/
ng build
ls -la dist/
There is no log error. Errror is that I expect that file .htaccess
is copied in dist
folder.
When you put it in src/assets/.htaccess
, it will be copied into dist/assets/.htaccess
.
If you want it to be in dist/.htaccess
, then you should be in src/.htaccess
AND you need to add it to angular-cli.json
in the assets
array (like favicon.ico
).
@filipesilva ,
in such case .htaccess
is copied in assets/.htaccess
.
I want to have assets
in the root of dest
folder.
If you think that it works can you give me the gist of your angular-cli.json
file?
Here is my gist
Change this bit:
"assets": [
"assets",
"favicon.ico"
],
to
"assets": [
"assets",
"favicon.ico",
".htaccess"
],
Now works. Thanks!
So, for others as reference here. is fix:
.htaccess
in src
folder (final path for is src/.htaccess) "assets": [
"assets",
"assets/images/favicon.ico",
".htaccess"
],
Kudos to @filipesilva !
unrelated... why are files in my assets folder ending up in
/dist
and in /dist/assets
?
Hey @filipesilva , can you please let me know what should be the content of .htaccess
?
I tried this, but of no use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
I have set <base href="http://146.148.47.134/mm-coming-soon/">
Need your guidance.
@arun-awnics I know this may be late but this is my .htaccess
file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) index.html [NC,L]
</IfModule>
But in my case, I have set <base href="/">
Hope this helps.
i have deployed the angular project on apache server and i have added .htaccess file in src folder but when i am refreshing the page at that time i am getting 404 error.
@sandipsanap try with RewriteBase /
you can change it to /dist for example or the name of your sub_directory
I know this might sound silly but angular.json has two sections, one for test and one for build. So add the entries to the correct one! :-)
I have generated the .htaccess
file. Now I want to make changes in .htaccess
file while building the angular build. currently I have the following in .htaccess
file.
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 ^ /test/index.html
I need to change the last line of this file RewriteRule ^ /test/index.html
.
How can i achieve it.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
When you put it in
src/assets/.htaccess
, it will be copied intodist/assets/.htaccess
.If you want it to be in
dist/.htaccess
, then you should be insrc/.htaccess
AND you need to add it toangular-cli.json
in theassets
array (likefavicon.ico
).