[英]How avoid 404 when using history API HTML5
You have to modify your webserver and enable mod_rewrite. 您必须修改您的Web服务器并启用mod_rewrite。 Then the server will take the request and forward it to your index file, and ember and SennaJS will parse the URL as you would expect.
然后,服务器将处理该请求并将其转发到您的索引文件,并且ember和SennaJS将按您期望的那样解析URL。
For Apache you need to enable mod rewrite and edit your vhost: 对于Apache,您需要启用mod重写并编辑您的虚拟主机:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
and nginx: 和Nginx:
rewrite ^(.+)$ /index.html last;
see: http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/ 参见: http : //readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.