Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess angular ui.router HTML5模式无法在apache中重新加载_.htaccess_Angular Ui Router - Fatal编程技术网

.htaccess angular ui.router HTML5模式无法在apache中重新加载

.htaccess angular ui.router HTML5模式无法在apache中重新加载,.htaccess,angular-ui-router,.htaccess,Angular Ui Router,我正在尝试从URL中删除“#” 使用带有ui sref或href属性的链接导航可以正常工作,但直接访问同一url,或刷新页面,或按enter键进入浏览器的url栏,我会发现404 not found错误 我启用了html5模式: $locationProvider.html5Mode(true); 在任何包含之前在头部添加基本标记: <base href="/folder/" /> 似乎是与.htaccess文件相关的问题 怎么了 我必须: 在/etc/apache2/apach

我正在尝试从URL中删除“#”

使用带有ui sref或href属性的链接导航可以正常工作,但直接访问同一url,或刷新页面,或按enter键进入浏览器的url栏,我会发现404 not found错误

我启用了html5模式:

$locationProvider.html5Mode(true);
在任何包含之前在头部添加基本标记:

<base href="/folder/" />
似乎是与.htaccess文件相关的问题

怎么了

我必须:

  • 在/etc/apache2/apache2.conf()中启用AllowOverride
  • 从终端启用mod_rewrite
    a2enmod rewrite
  • 从终端重新启动apache
    service apache2 restart
  • 我必须:

  • 在/etc/apache2/apache2.conf()中启用AllowOverride
  • 从终端启用mod_rewrite
    a2enmod rewrite
  • 从终端重新启动apache
    service apache2 restart
  • RewriteEngine on
    
    # 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 ^ /folder/index.html [L]