我试图从我的网站删除哈希标签.我已经通过以下代码实现了.
$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.