-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run angular 2 application on apache hosting server #11884
Comments
Hello, I guess Apache is looking for a /home directory in your root server By googling 10 seconds, this link solves your problem : https://github.com/mgechev/angular2-seed/wiki/Deploying-prod-build-to-Apache-2 |
To recite @vicb
|
Sorry to rock the boat, I hope this doesn't attract more questions. I'm only going to comment once :) @nikvarma for more details/questions, use gitter or stackoverflow like @manklu mentioned above.
Now, no matter what path you're requesting, Apache will always serve your |
Your question sounds like a support request. Please use the issue tracker only for bugs and feature requests. Use gitter and StackOverflow for support request. |
@MrCroft the link that @samfrach provides does it little differently. Care to expand upon the differences? <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule> |
@killrazor |
@samfrach thanks for link I am still getting problem. |
I have followed above methods. but I am getting the same 404 problem for urls except
And I have added the below code in
and my Apache's mod_rewrite extension also enabled. And i have given base url path in index.html like this |
As of 7/10, I can upload and serve the angular tutorial app without any tweak to my apache server config. Just remember to change the Eg. if your app's
in the header of |
@nicholaelaw Thanks for the reply. I have tried whatever you suggested. but its still showing the same 404 error.I changed the base href as you said. |
@Sathishchary yes, same for me. |
As of Angular 4.3.1, I find I still have to modify the .htaccess on the target deployment folders on GoDaddy, otherwise the browser reload problem occurs if the Angular app uses routing. When I try the simplistic approach of always serving index.html if a 404 occurs, I no longer get the proper file-missing error that ought to occur if my app attempts to load a .json file that doesn't exist. |
Official angular Guide: @dhrupal-ample You need a webserver to run (like ng serve), just opening in Browser will always be blank page. |
just to mention that one must definetely NOT use the .htaccess file when possible, use httpd.conf instead |
not every project is going to production @phil123456, many of us, who search the web are learning. if some tool or hack, solves a temporary problem for a learning project, so be it, happy to use it. |
@phil123456 could you link some article or discussion why not to use .htaccess? I couldn't find anything suitable. |
@iBaff indeed, hard to find relevant articles, although I read these advices many times on several occasions, been using apache for like 15 years now 1 https://security.stackexchange.com/questions/36641/does-disabling-htaccess-improve-security 2 we been hacked, recently, and security specialists (and our security team) disabled all htaccess, strongly suggesting us to leave vhosts configs on apache conf levels...guess these blokes know what they are doing 3 personaly I rather not put .htacess files knowing that they contain permisions/rules, just asside of public directories that might be retreived one day or tempered for one reason or another... 4 then we put apache itself in a chroot , not only the ftp, but the whole web server (yes it's a bloody pain in the a$$) 5 centralizing configs instead of spreading them here and there is clearly a better practice (although apache configs allows files inclusions, they end up all in the same folder, which is far better for maintenance, especialy under linux, especialy using the cli) |
@phil123456 thanks for your answer! Sad to hear that you have been hacked. |
Click this link for a working htaccess configuration. I was able to get it working after trying a lot of configurations |
This .htaccess worked for me:
|
@Sathishchary |
@gthomas2 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi Guys,
I have hosting plan and i want to host my angular 2 application on the hosting server which have apache server.
The hosting server don't have a npm install.
after below command and getting a like the strc
file strc
ng build --prod
and uploading to my hosting server, when i am accessing the my url
http://www.exmaple.com/ -- it's working properly
http://www.exmaple.com/home -- it's giving a error, the file is no found on the server - 404
but the same thing working on my machine, when i am trying using a cmd
ng serve - command
The text was updated successfully, but these errors were encountered: