2016-02-11 101 views
0

我在我的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. 

enter image description here 直视图angular.min.js文件更改为index.html的

回答

0

这不是因为您无法从服务器级别的URL中删除hash参数。服务器从来没有得到它,你可以通过查看Apache日志来验证它。

要使用UI路由器删除它,你需要将其设置为html5mode,然后它会在一个URL格式,您的服务器可以对其进行拦截:

app.config(["$locationProvider", function($locationProvider) 
{ 
    $locationProvider.html5Mode(true); 
}]); 

https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

+0

谢谢您的回答。但我已经将Html5Mode设置为true ...我的问题是不同的。为什么所有文件内容都改为index.html文件。见上图。 – Sandeep

+0

在上面的截图中,是否加载了'appjs.js'的内容,或者它是否也是'index.html'? *永远不会发现*我看到它的请求产生的错误。 – bbrown

相关问题