没有被应用为angularjs Apache的重写规则 [英] Apache rewrite rules not being applied for angularjs

查看:197
本文介绍了没有被应用为angularjs Apache的重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图安装的Apache 2.2 AngularJS与一个几乎精确的结构,从下面的封闭问题之一。

I am trying to setup apache 2.2 with AngularJS with an almost exact structure as the one from the following closed question.

<一个href=\"http://stackoverflow.com/questions/15284038/rewrite-rules-for-apache-2-to-use-with-angular-js\">rewrite Apache 2的规则具有角JS使用

我想重定向所有请求到App,除了请求/ API / index.html的。

I would like to redirect all requests to app/index.html except for requests to /api.

我的目录结构遵循


  • /

  • /应用程序

  • /app/index.html

  • /应用/ CSS

  • /应用/ JS

  • / API

我试图应用这些规则重定向中的httpd的虚拟主机文件,例如这是张贴了正确的答案的http:// stackoverflow.com/a/15284848/671095 来的问题。

I am trying to apply these redirect rules in the httpd-vhosts file as such which was posted as the correct answer http://stackoverflow.com/a/15284848/671095 to the question.

<VirtualHost *:80>
ServerName www.test.com
DocumentRoot "C:/websites/test"
Alias /CFIDE "C:/websites/CFIDE"

RewriteEngine On

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api

# otherwise forward it to index.html 
RewriteRule ^.*$ - [NC,L]
RewriteRule ^app/. /app/index.html [NC,L]

</VirtualHost>

然而,当我尝试访问/在浏览器中我与一个空白屏幕psented $ P $。如果我进入浏览器/app/index.html但我能在我的浏览器中查看HTML页面,但没有css.or的JS可以访问和返回一个404。

However when I try visit / in the browser I am presented with a blank screen. If I enter to /app/index.html in the browser however I am able to view the html page in my browser but none of the css.or js can be accessed and is returning a 404.

我一直打算在这个这似乎是一个简单的事情来完成作为Apache重写坚果。

I have been going nuts over this which seems like a simple thing to accomplish as an apache rewrite.

任何帮助将是非常美联社preciated

Any help would be much appreciated

推荐答案

<一个href=\"http://www.josscrowcroft.com/2012/$c$c/htaccess-for-html5-history-pushstate-url-routing/\">This对我的作品:

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) index.html [L]
</ifModule>

这篇关于没有被应用为angularjs Apache的重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆