- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遵循了 codelord.net" 实现推送状态的指示。并从 here 获得了 .htaccess 代码.
当我点击导航链接时,URL 看起来是正确的 (http://writers-tryst-test.ron-tornambe.com/about),但主页显示的是空白页面,所有其他页面显示 404 NOT FOUND。
我是 Linux 新手,对 .htaccess 根文件的位置有点困惑。我在 GoDaddy 共享服务器上。我将代码附加到包含 public_html 的同一文件夹中的 .htaccess 文件中。
.htaccess 编辑 - 新文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,QSA]
</IfModule>
Angular JS
angular.module('wtApp').config(function($locationProvider) {
$locationProvider.html5Mode(true);
});
var wtApp = angular.module('wtApp', ['ngRoute'])
wtApp.config(function ($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl: 'pages/home.html',
controller: 'mainController'
})
// route for the writers page
.when('/writers', {
templateUrl: 'pages/writers.html',
controller: 'writersController'
})
...HTML
<base href="/" />
我也试过在 href 前面加上正斜杠 (/)。
<div class="collapse navbar-collapse" id="Writers-Tryst">
<ul class="nav navbar-nav">
<li class="active"><a id="homepage" href="/"><i class="glyphicon glyphicon-home"></i> Home</a></li>
<li><a href="writers" class="glyphicon glyphicon-book"> Writers</a></li>
<li><a href="enablers" id="enablers-link" class="glyphicon glyphicon-thumbs-up"> Enablers</a></li>
<li><a href="about" class="glyphicon glyphicon-info-sign"> About</a></li>
<li><a href="privacy" class="glyphicon glyphicon-info-sign"> Privacy/Rules</a></li>
<li><a href="contact" class="glyphicon glyphicon-envelope"> Contact</a></li>
</ul>
最佳答案
你的重写一团糟。得到这样奇怪的东西:http://writers-tryst-test.ron-tornambe.com/writers-tryst-test.ron-tornambe.com/#//
现在,我开发了自己的版本,最终在 Apache 配置中使用了一个目录:
<Directory "S:/localhost/Apache24/Angular/routing-simple-evo">
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 ^ index.html [L]
</Directory>
如果你愿意,我认为你可以将目录标签内的内容直接粘贴到你的 htaccess 中,但出于某种原因,配置文件似乎工作得最好,或者恰好是我最终整理这些东西时正在工作的。
我要指出的唯一其他事情是顺序和分组;您的路由命令看起来与我今天看到的所有教程都不一样。以下是对我有用的:
// create the module and name it RoutingEvo
// also include ngRoute for all our routing needs
var RoutingEvo = angular.module('RoutingEvo', ['ngRoute']);
// configure our routes
RoutingEvo.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'http://angular.dev/routing-simple-evo/views/home.html',
controller : 'mainController'
})
// route for the about page
.when('/about', {
templateUrl : 'http://angular.dev/routing-simple-evo/views/about.html',
controller : 'aboutController'
})
// route for the contact page
.when('/contact', {
templateUrl : 'http://angular.dev/routing-simple-evo/views/contact.html',
controller : 'contactController'
});
});
//从路由中记录一些信息:
RoutingEvo.run([
'$rootScope',
function($rootScope) {
// see what's going on when the route tries to change
$rootScope.$on('$locationChangeStart', function(event, newUrl, oldUrl) {
// both newUrl and oldUrl are strings
console.log('Starting to leave %s to go to %s', oldUrl, newUrl);
});
}
]);
// create the controller and inject Angular's $scope
RoutingEvo.controller('mainController', function($scope) {
// create a message to display in our view
$scope.message = 'Everyone come and see how good I look!';
});
RoutingEvo.controller('aboutController', function($scope) {
$scope.message = 'Look! I am an about page.';
});
RoutingEvo.controller('contactController', function($scope) {
$scope.message = 'Contact us! JK. This is just a demo.';
});
我主要从以下方面将其组合在一起:
https://scotch.io/tutorials/single-page-apps-with-angularjs-routing-and-templating
https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag
-----老--------
将以下内容添加到应用程序根文件夹中的 .htaccess 文件(如果不存在,请创建一个 .htaccess 文件。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,QSA]
</IfModule>
关于javascript - 如何在 apache 上实现 Angular 推送状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37755083/
我正在通读 Windows Phone 7.5 Unleashed,有很多代码看起来像这样(在页面的代码隐藏中): bool loaded; protected override void OnNav
在cgi服务器中,我这样返回 print ('Status: 201 Created') print ('Content-Type: text/html') print ('Location: htt
我正在查看 esh(easy shell)的实现,无法理解在这种情况下什么是 22 和 9 信号。理想情况下,有一个更具描述性的常量,但我找不到列表。 最佳答案 信号列表及其编号(包括您看到的这两个)
我的Oozie Hive Action 永远处于运行模式。 oozie.log文件中没有显示错误。
我正在编写一个使用 RFCOMM 通过蓝牙连接到设备的 Android 应用程序。我使用 BluetoothChat 示例作为建立连接的基础,大部分时间一切正常。 但是,有时由于出现套接字已打开的消息
我有一个云调度程序作业,它应该每小时访问我的 API 以更新一些价格。这些作业大约需要 80 秒才能运行。 这是它的作用: POST https://www.example.com/api/jobs/
我正在 Tomcat 上访问一个简单的 JSP 页面: 但是当我使用 curl 测试此页面时,我得到了 200 响应代码而不是预期的 202: $ curl -i "http://localhos
有时 JAR-RS 客户端会发送错误的语法请求正文。服务器应响应 HTTP status 400 (Bad Request) , 但它以 HTTP status 500 (Internal Serve
我正在尝试通过 response.send() 发送一个整数,但我不断收到此错误 express deprecated res.send(status): Use res.sendStatus(sta
我已经用 Excel 和 Java 做过很多次了……这次我需要用 Stata 来做,因为保存变量更方便'labels .如何将 dataset_1 重组为下面的 dataset_2? 我需要转换以下
我正在创建一个应用程序,其中的对象具有状态查找功能。为了提供一些上下文,让我们使用以下示例。 帮助台应用程序,其中创建作业并通过以下工作流程移动: 新 - 工作已创建但未分配 进行中 - 分配给工作人
我想在 Keras 中运行 LSTM 并获得输出和状态。在 TF 中有这样的事情 with tf.variable_scope("RNN"): for time_step in range
有谁知道 Scala-GWT 的当前状态 项目? 那里的主要作者 Grzegorz Kossakowski 似乎退出了这个项目,在 Spring 中从事 scalac 的工作。 但是,在 interv
我正在尝试编写一个 super 简单的 applescript 来启动 OneDrive App , 或确保打开,当机器的电源设置为插入时,将退出,或确保关闭,当电源设置为电池时。 我无法找到如何访问
目前我正在做这样的事情 link.on('click', function () { if (link.attr('href') !== $route.current.originalPath
是否可以仅通过查看用户代理来检测浏览器上是否启用/禁用 Javascript。 如果是,我应该寻找什么。如果否,检测用户浏览器是否启用/禁用 JavaScript 的最佳方法是什么 最佳答案 不,没有
Spring 和 OSGi 目前的开发状况如何? 最近好像有点安静了。 文档的最新版本 ( http://docs.spring.io/osgi/ ) 来自 2009 年。 我看到一些声明 Sprin
我正在从主函数为此类创建一个线程,但即使使用 Thread.currentThread().interrupt() 中断它,输出仍然包含“Still Here”行。 public class Writ
为了满足并发要求,我想知道如何在 Godog 中的多个步骤之间传递参数或状态。 func FeatureContext(s *godog.Suite) { // This step is ca
我有一个UIButton子类,它不使用UIImage背景,仅使用背景色。我注意到的一件事是,当您设置按钮的背景图像时,有一个默认的突出显示状态,当按下按钮时,该按钮会稍微变暗。 这是我当前的代码。
我是一名优秀的程序员,十分优秀!