搜索引擎优化和301重定向 - 他们可以有相对的路径,还是必须是绝对的?
当对页面执行301重定向时,BOT/Spiders会将301转到相对路径(redirect ="../"),与转到绝对路径的路径相同(redirect ="http: //www.somewebsite.com/apage/").
例如,我有一个包含内容(http://www.somewebsite.com/apage/)的父页面...我有一个子页面(http://www.somewebsite.com/apage/more-details)进一步的内容.
我计划将更多内容移动到主页面本身并摆脱(http://www.somewebsite.com/apage/more-details),但我想使用301将机器人/浏览器重定向到页面在升级(http://www.somewebsite.com/apage/)所以我不会丢失任何页面排名等
我们有一段遗留代码(ab)fopen()通过HTTP 使用对资源的调用:
@fopen('http://example.com')
Run Code Online (Sandbox Code Playgroud)
我们希望将example.com移至另一台主机,然后发送"301 Permanently Moved",但是,我们并不完全确定是否@fopen()会遵循这一规定.
初步测试表明它没有.但也许我会错过一些配置文章.
我试图弄清楚如何在我的htaccess文件中执行301重定向以将一些文件重定向到新域.这是我需要知道如何做的:
旧网址:http://www.example.com/index.php? page = news&id = 2366
新网址:http://www.example2.com/news.php? name = 23546
重定向不必自动创建.我可以硬编码我需要在htaccess文件中重定向的页面,我只是不知道要使用的格式,因为我读过"标准"301重定向不适用于查询字符串.
基本上这就是我想做的事情,但到目前为止我的研究听起来并不像这样做.
redirect 301 /index.php?page=news&id=2366 http://www.example2.com/news.php?name=23546
Run Code Online (Sandbox Code Playgroud) 现在,我对301重定向没有任何问题,但有一个人问我为浏览器和搜索引擎撤消缓存301重定向的方法,所以我回复说"通过301重定向回原始网址",至少多数民众赞成我认为是解决方案,直到我看到人们提到你不能做301重定向回来 http://getluky.net/2010/12/14/301-redirects-cannot-be-undon/ http:/ /www.velocityreviews.com/forums/t500058-undo-301-redirect.html
这是一个惊喜,我不确定它是否属实,所以我要问的是,将页面/a.html中的缓存永久301重定向恢复到页面/b.html 的正确方法是什么到原来的/a.html?
我想要一些专家的意见.
browser redirect search-engine http-status-codes http-status-code-301
我将我的网站从old-domain.com移动到new-domain.com,页面完全相同,例如,如果old-domain.com有page1.html(即old-domain.com/page1.html)然后新域名具有相同的页面,即new-domain.com/page1.html
我在.htaccess文件中尝试过这个:
RewriteEngine on
RewriteRule (.*) http://new-domain.com/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
但只有当old-domain.com重定向到new-domain.com时,old-domain.com/page1.html 才会重定向到new-domain.com/page1.html
谢谢!
谷歌或任何其他抓取工具是否可以抓取并索引返回301状态代码的网页?
我在谷歌看过一个页面,它已经有301个月了.但是,索引中该页面的缓存日期是几天前的.
可以谷歌只是忽略301并抓取页面的内容?
我有一个要求,即不应将值缓存在服务器中,也不应将浏览器缓存为域和会话上的cookie.
所以我选择永久重定向到价值
Servlet的:
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String key = request.getParameter("key");
String val = request.getContentType();
if (val != null && val.length() == 0) {
val = null;
}
String repeatText = request.getParameter("repeatText");
if (val != null && repeatText == null) {
response.setStatus(301); // moved permanent
response.addHeader("Location", "?repeatText=" + val);
System.out.println("Write");
} else {
if (repeatText != null) {
response.setContentLength(repeatText.length());
response.addHeader("pragma", "no-cache");
response.addIntHeader("expires", BROWSER_CACHE_DAYS);
response.getWriter().write(repeatText);
System.out.println("Read and cache!");
} else {
response.sendError(304); // use …Run Code Online (Sandbox Code Playgroud) 我301重定向链接以跟踪点击.
http://myurl.tld/redirect.php?target=http%3A%2F%2Ftarget.tld%2Ffile.pdf
Run Code Online (Sandbox Code Playgroud)
我跟踪通话量和其他一些统计数据redirect.php.它运行良好,除非我重定向到Internet Explorer中的pdf文件(我测试了v11,可能会影响其他版本).
在这种情况下,redirect.php跟踪同一用户在几秒钟内完成的几十次点击.
使用fiddler我发现pdf以块(HTTP状态代码206 Partial Content)的形式返回,这意味着会发出多个请求而不是一个请求.
通常情况下,您希望浏览器在以块为单位传递pdf http://target.tld/file.pdf时进行后续调用target.tld,这正是大多数浏览器所做的.
但是,Internet Explorer决定http://myurl.tld/redirect.php?target=http%3A%2F%2Ftarget.tld%2Ffile.pdf一次又一次地请求,而不是请求目标站点.
现在我的问题:
我怎么能告诉IE不要打电话myurl.tld而是target.tld?
我可以操纵301重定向中的标头,以便IE知道从中请求文件target.tld吗?
我可以使用Global.asax的开始请求重定向一切,
从mydomain.domain到www.mydomain.domain?
如果这个是真的,我该怎么做?
使用URLConnection时,301重定向不起作用,甚至不Location使用getHeaderFields()显示标题.它是一个空白列表,除了较新的Android(我测试4.1并且它工作).它看起来像这样的东西已经被报道在默认浏览器在这里为好,但在我的测试中它的Android浏览器的工作.在旧的Android中是否有针对此错误的解决方法?
我试过了:
URLConnection conn = u.openConnection();
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
(conn).setInstanceFollowRedirects(true);
Run Code Online (Sandbox Code Playgroud)
但它仍然会返回一个空列表,除了较新的Android.
更新:这可能是一个相关的问题,有时似乎URLConnection甚至没有在某些情况下发送请求.(我在带有模拟器的电脑上查看了Wireshark).有办法解决这个错误吗?
更新:我尝试测试3xx重定向,重定向工作正常,但普通链接不适用于Ian的Cookie管理器.确保在openConnection之后直接调用setCookies时,它可以很好地工作:
URL u = new URL(_url);
...
int tries = 4;
int code = 301;
URLConnection conn = null;
while (tries > 0 && code/100 == 3) {
conn = null;
conn = u.openConnection();
_CM.setCookies(conn);
((HttpURLConnection)conn).setInstanceFollowRedirects(false);//Required
code =((HttpURLConnection)conn).getResponseCode();
if (code/100 == 3) {
String loc = conn.getHeaderField("Location");
u = new URL(loc);
}
}
//conn.addRequestProperty("Accept-Encoding", "gzip");
conn.connect();
_CM.storeCookies(conn);
Run Code Online (Sandbox Code Playgroud)
真正奇怪的是,对于较新的Android(4.1模拟器),FollowRedirect行(注释为"必需")不是必需的.在较旧的Android(2.2)上,它会Connection Reset …