【问题标题】:Angularjs on https and httphttps和http上的Angularjs
【发布时间】:2014-03-14 07:13:54
【问题描述】:

我尝试了不同的方法,只在 https 上将登录页面创建到服务器,而在应用程序的其余部分使用 http,但没有成功。

版本:1.2.14 网络服务器:Apache 2.2

我尝试了以下方法:

  1. 删除 # 并使其成为漂亮的 url,但这不起作用。尝试将 locationprovider html5 enable 添加为 true 并在 .htaccess 中添加重写规则

  2. 在 apache 中尝试了不同的 rewritecond 和 rewriterule 来识别登录模式并重定向到 https,但没有成功

RewriteEngine On  
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(/?login/)$ https://www.domain.com/%{REQUEST_URI} [L,R]

注意:我的登录网址开头如下:

http://www.domain.com/#/login/

谢谢

【问题讨论】:

  • 任何人的帮助。

标签: apache angularjs .htaccess


【解决方案1】:

启用

locationProvider.HTML5mode(true);

把它放在你的 index.html 文件的顶部:

<html ng-app="app">
<head>
 <base href="http://www.domain/#/" />

将此添加到您的 .htaccess 文件中

RewriteEngine on
RewriteBase /Projects/www
# 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 ^ index.html [L]

【讨论】:

  • 这对我的场景没有帮助,我想要一些页面在 https 中,其余页面在 http 中。
猜你喜欢
  • 2018-02-20
  • 1970-01-01
  • 1970-01-01
  • 2014-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-31
  • 1970-01-01
相关资源
最近更新 更多