链接到不是root用户的AngularJS站点

时间:2013-05-31 19:57:23

标签: javascript apache angularjs

我已经建立了一个有角度的网站。一切都很好。如果我去localhost它就会很好地调出主页。我可以点击一个链接,它会把我带到那里很好,但是如果我在不在根页面时刷新页面,或者如果我尝试输入一个URL它会给我一个404.我有{{1设置为true。怎么解决这个问题?我认为它会在apache的httpd.conf中,但我不确定。

2 个答案:

答案 0 :(得分:1)

使用<base href="/" />标记

答案 1 :(得分:0)

本文对问题进行了很好的描述:

http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url-routing/

它建议将此添加到您的.htaccess文件中(您也可以将其直接添加到您的apache conf中)。你必须将mod_rewrite加载到apache中。

# html5 pushstate (history) support:
<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) index.html [L]
</ifModule>
相关问题