加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php – 角度HTML5模式,路由器将重新加载页面

发布时间:2020-05-25 09:37:01 所属栏目:PHP 来源:互联网
导读:我试图从我的网站删除哈希标签.我已经通过以下代码实现了. $locationProvider.html5Mode(true); 以及索引文件中添加的基本URL. 我的问题是,如果我在重新加载整个页面后接受cont状态.我正在重定向到定义为其他状态的本地状态. 使用的配置是 – 服务器-Appache

我试图从我的网站删除哈希标签.我已经通过以下代码实现了.

$locationProvider.html5Mode(true);

以及索引文件中添加的基本URL.

我的问题是,如果我在重新加载整个页面后接受cont状态.我正在重定向到定义为其他状态的本地状态.

使用的配置是 –

服务器-Appache
数据库 – mysql

我在.htaccess中添加了以下代码来重写规则,

RewriteEngine On
     php_value post_max_size 120M 
    php_value upload_max_filesize 120M 
     php_value max_execution_time 90 



     RewriteCond %{HTTP_HOST} ^54.201.153.244$[NC,OR]

     RewriteCond %{HTTPS} off
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

      RewriteCond %{HTTP_HOST} ^adkarlo.com$[NC]
        RewriteRule ^(.*)$https://www.adkarlo.com/$1 [R=301,L]

      #RewriteBase /html/
      ErrorDocument 404 /404.php

    RewriteCond %{REQUEST_FILENAME} -f
     RewriteRule ^ - [L]
   RewriteRule ^(.*)$index.php [L]

预期结果 – 从国家联系人重新加载任何页面我想去同一页面.

为了支持重新加载HTML5模式路由URL,您需要实现服务器端URL重写,以将非文件请求(即,不是显式的现有文件的请求)引导到索引文件,通常为index.html .

从documentation

Using this mode requires URL rewriting on server side,basically you have to rewrite all your links to entry point of your application (e.g. index.html).

您的重写规则在目标网址中不应有#.相反,使用这个

RewriteEngine on

# Don't rewrite files
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.php [L]

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

另外,不需要设置RewriteBase.

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读