I built an Angular project, and this is my first time actually deploying a website. I used the command ng build
and I got a dist
folder with the ready Angular project called FitnessForm
.
我建立了一个Angular项目,这是我第一次真正部署网站。我使用了ng-build命令,并获得了一个dist文件夹,其中包含名为FitnessForm的现成Angular项目。
I watched a few tutorials, and they said to edit the .htaccess
folder, but I had a bit of trouble following them. I'll provide my htaccess folder
here in case anyone wants to take a look at it. I'll also indicate which lines I edited by the # I EDITED
comment.
我看了一些教程,他们说要编辑.htaccess文件夹,但我在遵循它们时遇到了一些麻烦。我会在这里提供我的htaccess文件夹,以防有人想看一看。我还会用#I edited评论指出我编辑了哪些行。
# BEGIN Newfold Headers
<IfModule mod_headers.c>
Header set X-Newfold-Cache-Level "2"
</IfModule>
# END Newfold Headers
# BEGIN Newfold Browser Cache
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 24 hours"
ExpiresByType text/html "access plus 2 hours"
ExpiresByType image/jpg "access plus 24 hours"
ExpiresByType image/jpeg "access plus 24 hours"
ExpiresByType image/gif "access plus 24 hours"
ExpiresByType image/png "access plus 24 hours"
ExpiresByType text/css "access plus 24 hours"
ExpiresByType text/javascript "access plus 24 hours"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
# END Newfold Browser Cache
# BEGIN Newfold File Cache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wp-content/newfold-page-cache/ - [L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
RewriteCond %{HTTP:Cache-Control} ^((?!no-cache).)*$
RewriteCond %{DOCUMENT_ROOT}/wp-content/newfold-page-cache/$1/_index.html -f # I EDITED
RewriteRule ^(.*)$ ./angularApp/index.html [L] # I EDITED
</IfModule>
# END Newfold File Cache
# BEGIN Newfold Skip 404 Handling for Static Files
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^./angularApp/ # I EDITED
RewriteCond %{REQUEST_URI} \.(css|htc|less|js|js2|js3|js4|html|htm|rtf|rtx|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|avif|avifs|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|webm|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip)$ [NC]
RewriteRule ^(.*)$ ./angularApp/$1 - [L] # I EDITED
</IfModule>
# END Newfold Skip 404 Handling for Static Files
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 2 hours"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 6 hours"
</IfModule>
Options -Indexes
<IfModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
Header set X-nginx-cache "WordPress"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.html$ - [L] # I EDITED
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(/)?$ ./angularApp/index.html [L] # I EDITED
</IfModule>
# END WordPress
My folder on Bluehost looks like this.
我在Bluehost上的文件夹是这样的。
.
└── public_html/
├── angularApp/
│ ├── index.html
│ └── // other neccassary files
└── htaccess
In case it's also important, my domain name is yousfandabdulmalik.website
如果它也很重要,我的域名是yousfandabdulmalik.com
If anyone can help me get my website up and running, then that would be great. If I need to do anything else, please let me know.
如果有人能帮我启动并运行我的网站,那就太好了。如果我需要做其他事情,请告诉我。
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!