从Apache服务器的angularJS应用中的URL中删除#号
问题描述:
我在我的PC中使用Apache服务器。我在angularJS应用程序中阅读了一些关于从URL中删除#号的教程。 Apache服务器将指令的所有文件替换为index.html。虽然文件名称相同,但它的内容替换为index.html文件内容。请帮助我。我添加一些代码到C:\ XAMPP的\ apache的\的conf \ httpd.conf中从Apache服务器的angularJS应用中的URL中删除#号
# <VirtualHost> definition. These values also provide defaults for
<VirtualHost *:8000>
ServerName localhost
DocumentRoot "C:/xampp/htdocs/googleSignin/"
<Directory "C:/xampp/htdocs/googleSignin/">
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule^- [L]
# If the requested resource doesn't exist, use index.html
RewriteRule^/index.html
</Directory>
</VirtualHost>
# any <VirtualHost> containers you may define later in the file.
答
这不是因为您无法从服务器级别的URL中删除hash
参数。服务器从来没有得到它,你可以通过查看Apache日志来验证它。
要使用UI路由器删除它,你需要将其设置为html5mode
,然后它会在一个URL格式,您的服务器可以对其进行拦截:
app.config(["$locationProvider", function($locationProvider)
{
$locationProvider.html5Mode(true);
}]);
谢谢您的回答。但我已经将Html5Mode设置为true ...我的问题是不同的。为什么所有文件内容都改为index.html文件。见上图。 – Sandeep
在上面的截图中,是否加载了'appjs.js'的内容,或者它是否也是'index.html'? *永远不会发现*我看到它的请求产生的错误。 – bbrown