我正在使用AngularJS和ui.router.我已经看到Hashbang和
HTML5模式的行为差异,我想知道它是否可以更改/阻止.
使用时
使用时
$locationProvider.html5Mode(true);
当我手动更改地址栏中的URL时,会发生整页重新加载.
例如,如果我目前在网址上
http://example.com/post/5467777
并手动将其更改为
http://example.com/post/5464777
发生拉页重新加载,然后加载正确的状态.
如果我不使用HTML5模式,则不会发生整页重新加载,而是在更改网址时直接加载状态(当然要快得多)
http://example.com/#/post/5467777
到另一个.
我对HTML5模式的服务器端配置如下所示:
# Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ index.PHP [L]
我认为AngularJS也可以拦截这些URL更改.如果可能,在HTML5模式下手动更改URL时,如何才能重新加载页面?
谢谢