简体   繁体   English

Angular JS-LocationProvider HTML5mode()和网址

[英]Angular js - LocationProvider HTML5mode() and urls

i've enabled the 我已经启用了

locationProvider.HTML5mode(true);

then i putted on top of index.html : 然后我放在index.html之上:

<html ng-app="app">
<head>
 <base href="/projects/www/#/" />

So if i browse the site using internal links for example(#/users) everything works and urls are re-writed from projects/www/#/users to projects/www/users 因此,如果我使用内部链接浏览网站,例如(#/ users)一切正常,则URL从projects/www/#/users重写为projects/www/users

BUT if i go directly by browser to projects/www/users i get page not found. 但是,如果我直接通过浏览器转到projects/www/users找不到页面。

The only one direct url that works is : 唯一有效的直接网址是:

projects/www/

What this could be? 这可能是什么?

Ok i fixed it was to add some server side htaccess code: 好吧,我修复了添加一些服务器端htaccess代码的问题:

RewriteEngine on
RewriteBase /Projects/www
# 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.html [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM