我需要将每个http://test.com请求重定向到http://www.test.com.如何才能做到这一点.
在服务器块中我尝试添加
rewrite ^/(.*) http://www.test.com/$1 permanent;
Run Code Online (Sandbox Code Playgroud)
但它在浏览器中说
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.
Run Code Online (Sandbox Code Playgroud)
我的服务器块看起来像
server {
listen 80;
server_name test.com;
client_max_body_size 10M;
client_body_buffer_size 128k;
root /home/test/test/public;
passenger_enabled on;
rails_env production;
#rewrite ^/(.*) http://www.test.com/$1 permanent;
#rewrite ^(.*)$ $scheme://www.test.com$1;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Run Code Online (Sandbox Code Playgroud) 有一个隐藏版本的选项,因此它只显示nginx,但有没有办法隐藏它,所以它不会显示任何内容或更改标题?
我试图在一些页面内使用jQuery的页面滚动,并且可以成功地使页面滚动顺畅.我现在唯一的问题是尝试从不同的页面执行此操作.我的意思是,如果我点击页面中的链接,它应该加载新页面,然后滚动到特定的div元素.
这是我用于在页面内滚动的代码:
var jump=function(e)
{
//prevent the "normal" behaviour which would be a "hard" jump
e.preventDefault();
//Get the target
var target = $(this).attr("href");
//perform animated scrolling
$('html,body').animate(
{
//get top-position of target-element and set it as scroll target
scrollTop: $(target).offset().top
//scrolldelay: 2 seconds
},2000,function()
{
//attach the hash (#jumptarget) to the pageurl
location.hash = target;
});
}
$(document).ready(function()
{
$('a[href*=#]').bind("click", jump);
return false;
});
Run Code Online (Sandbox Code Playgroud)
我希望这个想法很清楚.
谢谢
非常重要注意:我上面发布的这段代码在同一页面内工作得很好,但我所追求的是从一个页面单击一个链接然后转到另一个页面,然后滚动到目标.我希望现在很清楚.谢谢
我刚刚注意到,当我在FireFox浏览器上查看我的mootool.js脚本时,会弹出一条警告消息.
警告消息是" 未声明纯文本文档的字符编码.如果文档包含来自US-ASCII范围之外的字符,则文档将在某些浏览器配置中使用乱码文本呈现.文件的字符编码需要是在传输协议或文件中声明需要使用字节顺序标记作为编码签名.
这是否意味着我必须添加Charset或其他什么?但它是一个脚本!!
这有解决方案吗?
如何从https重定向到http?
我有下面的代码,但它似乎不起作用.
server {
listen 443;
server_name example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
Run Code Online (Sandbox Code Playgroud) 当我输入我的域名时没有www(喜欢http://example.com),它不起作用并给出错误信息.但是,当我添加www它(如http://www.example.com)时,它的工作原理.
是不是应该双向工作(有和没有www)?
我有一个SSL分配给我的主域名,我想知道我是否可以使用SSL到我的子域!我坦率地试了一下,但它显示警告页面说这个页面不安全等等.有没有解决方案,所以我可以在我的子域上使用SSL让客户端在安全连接上发送他们的信息.
错误消息 " This webpage is not available"
我试图从做一个div跳转<a href="#FAQ">FAQ</a>到一个divID,可能容易成功,但因为我有一个固定的链接跳转到,我似乎无法找到一种方法如何做到这一点.
意思是,我想要一个div或一个href链接跳转到同一页面中的url说<a href="http://www.mydomain.ask.html">Ask</a>
我肯定知道从一个锚点跳到<a href="#jump">jump</a>一个div这样的<div id="jump">jump to point</div>工作正常.但是,相反的方式呢?它有用吗?我的意思是从div id跳到锚点工作?
我只是想知道同时使用Xcache 3和Zend Opcache缓存PHP文件是愚蠢的吗?我知道两者几乎都做同样的工作,但不确定这是否会对性能和速度产生任何影响.
我想加快我的php页面加载速度,以便访问者不需要等待很长时间.
有什么想法吗?
我有
server {
listen 80;
server_name domain1 domain2 domain3
location / {
proxy_pass http://127.0.0.1:8088;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}
}
server {
listen domainX:80;
server_name domainX www.domainX
location / {
proxy_pass http://127.0.0.1:8088;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}
location ~* \.(jpeg|jpg|gif|png|ico|bmp|swf|css|js)$ {
root domainXStaticRoot
}
# other options for domainX only
}
Run Code Online (Sandbox Code Playgroud)
对于来自第一个服务器块的域,nginx仅返回根页面:
http://domain1 -> returns root page for …Run Code Online (Sandbox Code Playgroud)