我正在研究使用HTML5 History API解决与AJAX加载内容的深层链接问题,但我正在努力开始.有没有人知道有什么好的资源?
我想使用它,因为它似乎是一种很好的方式,允许发送链接的可能性可能没有JS打开.当有人向JS发送链接给某人时,很多解决方案都会失败.
我最初的研究似乎指向JS中的History API和pushState方法.
我们有一个企业应用程序,它为客户端使用Angular 2.我们每个客户都有自己独特的网址,例如:https://our.app.com/customer-one和https://our.app.com/customer-two.目前我们可以<base href...>动态设置document.location.所以用户点击https://our.app.com/customer-two并<base href...>设置为/customer-two......完美!
问题是,如果用户是例如,https://our.app.com/customer-two/another-page并且他们刷新页面或尝试直接点击该URL,则<base href...>设置为get /customer-two/another-page并且找不到资源.
我们尝试了以下无济于事:
<!doctype html>
<html>
<head>
<script type='text/javascript'>
var base = document.location.pathname.split('/')[1];
document.write('<base href="/' + base + '" />');
</script>
...
Run Code Online (Sandbox Code Playgroud)
不幸的是,我们的想法很新鲜.任何帮助都会很棒.
upstream apache {
server 127.0.0.1:8080;
}
server{
location ~* ^/service/(.*)$ {
proxy_pass http://apache/$1;
proxy_redirect off;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码片段会将url包含字符串"service"的请求重定向到另一台服务器,但它不包含查询参数.
几周前,亚马逊宣布他们已经降低了内容的有效期:
实际上,您可以将CloudFront中的TTL设置为0.所以我的问题是,为什么将TTL设置为0的CloudFront分配有用.对我而言,这意味着根本没有缓存,因此每个到达CloudFront的请求都是如此.最终会击中原点.
我错过了什么?
我使用S3来存储一些关键业务文档.我希望存储桶在尝试访问存储桶中不存在的对象时返回404状态代码.
但是,我发现它一直让我回归"403
这是使用S3网站URL的会话示例.
> GET /foobar.txt HTTP/1.1
> User-Agent: curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: <bucketname>.s3-website-us-east-1.amazonaws.com
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Last-Modified: Mon, 09 Sep 2013 19:10:28 GMT
< ETag: "14e13b81b3ce5b129d1f206b3e514885"
< x-amz-error-code: AccessDenied
< x-amz-error-message: Access Denied
< x-amz-request-id: <snip>
< x-amz-id-2: <snip>
< Content-Type: text/html
< Content-Length: 11
< Date: Thu, 26 Sep 2013 20:01:45 GMT
< Server: AmazonS3
<
Not found!
Run Code Online (Sandbox Code Playgroud)
注意,"未找到!" 启用S3网站托管时,字符串来自桶属性上设置的错误文档.
我也尝试直接使用桶URL访问
HTTP://.s3.amazonaws.com/
除了错误文档而不是错误文档之外,我得到一个XML文档
我该如何解决这个问题?
我正在研究MVC 5项目.当我在我的视图中使用html页面时,它会加载该页面,但是当我使用.cshtml页面时,它不会加载视图.出现空白页面.
$urlRouterProvider
.otherwise('/app/dashboard');
$stateProvider
.state('app', {
abstract: true,
url: '/app',
templateUrl: 'tpl/app.html'
})
.state('app.dashboard', {
url: '/dashboard',
templateUrl: 'tpl/app_dashboard.html'
})
Run Code Online (Sandbox Code Playgroud)
请指导我如何使用cshtml文件或最佳方法.
如何配置Amazon S3静态网页以正确路由Angular ui.router html5Mode路由?在页面刷新时,它将请求不存在的文件,而angular不能处理它.在文档中,他们建议您更改服务器上的URL重写.
但是,S3是存储,并且不提供我尝试使用内置重定向规则的相同重定向选项,例如
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals >
</Condition>
<Redirect>
<HostName>[[ your application's domain name ]]</HostName>
<ReplaceKeyPrefixWith>#/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
Run Code Online (Sandbox Code Playgroud)
但是,这只会导致重定向循环.
有什么建议?
我已经通过很多的这样的堆栈溢出类似的问题了一个.每个人都有不同的角度来部署反应应用程序.
但是这个问题适用于那些使用redux,react-router和react-router-redux的人.我花了很多时间来确定托管单页面应用程序的正确方法.我正在汇总这里的所有步骤.
我写了下面的答案,其中包含将react-redux app部署到S3的步骤.
amazon-s3 amazon-web-services reactjs react-router react-router-redux
amazon-s3 ×4
angular ×2
angularjs ×2
html5 ×2
javascript ×2
asp.net-mvc ×1
aurelia ×1
c# ×1
cdn ×1
nginx ×1
parameters ×1
pushstate ×1
razor ×1
react-router ×1
reactjs ×1