客户端应该表现得与众不同吗?怎么样?
我正在调试HTTP 301永久重定向的问题.经过快速测试后,似乎Safari在重启时清除了301s的缓存,但Firefox却没有.
IE,Chrome,Firefox和Safari什么时候清除301s的缓存?
更新:例如,如果我想重定向example1.com
到example2.com
,但我不小心将其设置为重定向到example3.com
,这是一个问题.我可以纠正错误,但是example1.com
在此期间访问过的任何人都会将错误的重定向缓存到example3.com
,因此他们将无法访问example1.com
或者example2.com
直到他们的缓存被清除.经过调查,我发现,没有Cache-Control
和Expires
标题设置.不正确的301响应的标头将是这样的:
HTTP/1.1 301 Moved Permanently
Date: Wed, 27 Feb 2013 12:05:53 GMT
Server: Apache/2.2.21 (Unix) DAV/2 PHP/5.3.8
X-Powered-By: PHP/5.3.8
Location: http://example3.com/
Content-Type: text/html
Run Code Online (Sandbox Code Playgroud)
我自己的测试表明:
HTTP 301
和308
状态代码有什么区别?
301
(永久移动):此和所有将来的请求应定向到给定的URI.
308
(永久重定向):应使用另一个URI重复请求和所有将来的请求.
他们似乎很相似.
http http-status-codes http-status-code-301 http-status-code-308
我在github页面上有博客 - jekyll
解决URL策略迁移的最佳方法是什么?
我发现最常见的做法就是创建像这样的htaccess
Redirect 301 /programovani/2010/04/git-co-to-je-a-co-s-tim/ /2010/04/05/git-co-to-je-a-co-s-tim.html
Run Code Online (Sandbox Code Playgroud)
但它似乎与Github无关.我找到的另一个解决方案是创建rake任务,它将生成重定向页面.但由于它是一个html,它无法发送301
头,因此SE爬虫不会将其识别为重定向.
重新设计网站后,我有几页需要重定向.一切都停留在同一个域上,只有一些东西被重新组织和/或重命名.它们的形式如下:
/contact.php
就是现在:
/contact-us.php
使用.htaccess文件,我添加了这一行,这是我最常推荐的那一行:
RedirectMatch 301 /contact.php /contact-us.php
Run Code Online (Sandbox Code Playgroud)
这很好 - 它完成了工作 - 问题是,它还重定向:
有没有办法指定我只想重定向根目录中的contact.php?
我有一个新的作者网站,我希望从我之前使用Apache重写的域中提供,以便将流量反弹到我的亚马逊网站,[R = 301,L],我想将其作为我自己的网站提供.我至少还有一个新的域名.
是否存在特定的持续时间,特别是Chrome将存储301缓存重定向?其他一些问题,浏览器缓存HTTP 301s需要多长时间?以及不同浏览器如何实现301重定向?,问,并给出答案,一些浏览器不缓存,一些缓存用于会话,Chrome和IE10缓存的方式将在浏览器重启后继续存在,但不指定多长时间.比其他测试的浏览器更长,但数量仍未指定.
那么Chrome存储301重定向需要多长时间?引用的问题没有说明Chrome或IE10的含义.
google-chrome http-redirect http-response-codes http-status-code-301
我有domain.com.如果用户已登录,则应自动加载domain.com/option-X,其中X是用户的预定义选项.
所以,我在index.php的顶部这样做:
header("Location: /option-X");
Run Code Online (Sandbox Code Playgroud)
但是,如果用户未登录,我只需自动选择第一个选项,如下所示:
header("HTTP/1.1 301 Moved Permanently");
header("Location: /option-a");
Run Code Online (Sandbox Code Playgroud)
所以,我有两个问题涉及这样做的含义:
我无法找到我的问题的直接答案,需要从真正的专家那里了解它.
我有一个网站,网址由Joomla生成.我相信在搜索引擎中有大量的网址,我真的不知道它们中的哪一个.302重定向将是一个选项,但我不能说哪些网址需要重定向.
我唯一知道所有网址都是由sef404脚本生成的,它是Joomla的SEO脚本.
我的问题是,我怎样才能确保谷歌和其他搜索引擎上的所有孤儿网址都使用.htaccess文件正确发送?
如何301将所有404页面重定向到主页(根文档)
目前我使用自定义的404.html错误文件,但文件太多,会给自定义404错误页面的过山车
我有以下nginx配置片段:
server {
listen 80;
server_name mydomain.io;
root /srv/www/domains/mydomain.io;
index index.html index.php;
access_log /var/log/nginx/domains/mydomain.io/access.log;
error_log /var/log/nginx/domains/mydomain.io/error.log;
location ~\.php {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
首先,如何使服务器块响应both
http://www.mydomain.io和http://mydomain.io.其次,如果他们来自http://www.mydomain.io重定向到http://mydomain.io,我想强制.
谢谢.
我想知道301重定向是否始终保留referrer.
我创建了一个名为"gotoorig_https.html"的页面,其中包含指向页面"orig_https.asp"的超链接.
"orig_https.asp"将301重定向到显示document.referrer的"dest.html".
在这种情况下,
http page(gotoorig_https.html) -> orig_https.asp(301 redirect)-> https page (dest.html) <--the referrer preserves
https page(gotoorig_https.html) -> orig_https.asp(301 redirect)-> https page (dest.html) <--the referrer preserves
Run Code Online (Sandbox Code Playgroud)
我还创建了一个名为"gotoorig_http.html"的页面,其中包含指向页面"orig_http.asp"的超链接."orig_http.asp"将301重定向到"dest.html",显示document.referrer.
在这种情况下,
http page(gotoorig_http.html) -> orig_http.asp(301 redirect)-> http page (dest.html) <--the referrer preserves
https page(gotoorig_http.html) -> orig_http.asp(301 redirect)-> http page (dest.html) <--the referrer DOES NOT preserve.
Run Code Online (Sandbox Code Playgroud)
为什么最后一种情况发生?