.htaccess for angular html5 redirect not working

时间:2015-04-27 16:27:38

标签: angularjs html5 apache .htaccess

我的.htaccess文件:

RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]

    RewriteRule ^(.*) /index.html [NC,L]

放在根目录(与index.html一起)内。但是,当我刷新时,我收到错误:The requested URL <url> was not found on this server。 同一个网址正在应用链接中运行。我的.htaccess文件有问题吗?

1 个答案:

答案 0 :(得分:0)

你有一条规则:

RewriteRule ^.*$ - [NC,L]

index.html以上index.html规则,因此我猜测^.*$规则甚至无法处理。更不用说-规则似乎没有形成,因为L flag。相反,您似乎正在将所有请求重写为破折号(RewriteEngine on RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .* /index.html [QSA,NC,L] )。

将文件更改为:

class Variables
{
private:
    Variables () {} // to prevent instantiation, which makes no sense
public:
    static map<string , int> myMap;
    static float numba;
};

float Variables::numba = 0;
map<string , int> Variables::myMap = map<string, int>;
//somehow initialize your static variables