标签: http-status-code-301

301将index.html重定向到/或/index.php

问候,

我刚刚将一个网站从IIS移动到Apache,并且在重定向索引文件时遇到一些麻烦,而不会导致无限循环.

这两者都将导致循环 -

重定向301 /index.htm /index.php

重定向301 /index.htm http://www.foo.com/

下面是我当前.htaccess的副本.有人能帮我吗?我有一堆指向http://www.foo.com/index.htm的链接,我想将301重定向到http://www.foo.com/

RewriteEngine On

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying …
Run Code Online (Sandbox Code Playgroud)

apache mod-rewrite http-status-code-301

6
推荐指数
2
解决办法
2万
查看次数

全局301从域重定向到www.domain

我可以使用Global.asax的开始请求重定向一切,

mydomain.domainwww.mydomain.domain

如果这个是真的,我该怎么做?

vb.net asp.net global-asax http-status-code-301

6
推荐指数
2
解决办法
7486
查看次数

我需要多长时间来维护旧网址?

好的,我知道最佳做法是,一旦您更改或删除页面URL,将该URL重定向到新的相关URL.

但是持续多久?永远?

例如,我使用Google网站优化工具来测试网页的不同变体.所以我必须为每个创建一个不同的url:original.php,var1.php,var2.php等.

一旦测试完成,获胜者将成为新的original.php,并且不需要保留var1.php等.但我现在需要将那些不再需要的URL重定向到相关的original.php.

这可能最终导致我的.htaccess文件中有301个重定向.我也听说你的.htaccess文件中的东西越多,你的网站变得越慢,因为服务器必须先处理其中的所有内容才能提供一个页面.

我可以将重定向移动到实际的URL(例如实际的var1.php文件上的php重定向)但是我有几个不需要的文件膨胀我的服务器.

所以我想知道这里最好的做法是什么?这么长时间后删除301重定向是否安全?

php redirect http-status-code-301

6
推荐指数
1
解决办法
238
查看次数

301重定向:为什么连接关闭?

我学会了Connection: close在Java中进行301重定向时使用

response.setStatus(301);
response.setHeader("Location", "http://www.example.com/");
response.setHeader("Connection", "close");
Run Code Online (Sandbox Code Playgroud)

我们为什么要做这个?为什么不省略最后一行?

我在至少三个例子中看到了这一点,包括这个例子:http://www.pardontheinformation.com/2010/09/java-servlet-jsp-301-and-302-redirect.html

我从未见过最后一行省略.

java redirect http http-status-code-301

6
推荐指数
1
解决办法
3506
查看次数

使用301/303/307重定向进行动态短网址

我们正在实施一个短网址服务,其中重定向目标将每天更改.网址将由移动设备访问,并始终是GET请求.我试图了解哪种是最适合工作的300型重定向.

AFAIK大多数网址缩短服务使用301重定向(永久移动).但是,根据规格,303(见其他)和307(暂时移动)重定向似乎是为我们的案例设计的......

  • 303/307是否也支持301?规范说它们只在HTTP 1.1中实现 - 这个拼写有什么限制?
  • 选择301 vs 303/307是否有任何实际的缓存或性能影响.
  • 对于GET请求,有没有理由选择303 vs 307?
  • 有没有理由使用302重定向?
  • 还有其他要考虑的事情吗?

redirect http url-shortener http-status-code-301 http-status-code-307

6
推荐指数
1
解决办法
3801
查看次数

这个C#动作方法代码是否实际触发301重定向?

以下是有人访问我的电子商务网站上的产品页面时使用的代码.

public ActionResult Details(int id, string slug)
{
    using (var productRepository = new EfProductRepository())
    {
        var product = productRepository.FindById(id);
        if (product == null) return RedirectToAction("Index", "Home");
        if (product.SeoTextSlug != slug)
            return RedirectToAction("Details", new {id = product.ProductId, slug = product.SeoTextSlug});

        var model = new ProductDetailModel();

        //Load the product information.
        model.Product.ProductId = product.ProductId;
        model.Product.CoverImagePath = product.CoverImagePath;
        model.Product.Name = product.Name;
        model.Product.Tagline = product.Tagline;
        model.Product.Price = product.Price;
        model.Product.Stock = product.Stock;
        model.Product.PieceCount = (int)product.PieceCount;
        model.Product.SKU = product.SKU;

        //Load the reviews for that product.
        if (product.Reviews.Any()) …
Run Code Online (Sandbox Code Playgroud)

c# redirect actionmethod http-status-code-301 asp.net-mvc-3

6
推荐指数
1
解决办法
1506
查看次数

301/302重定向无法在Android中运行(在不同版本中的工作方式不同)

使用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 …

java redirect android urlconnection http-status-code-301

6
推荐指数
1
解决办法
5358
查看次数

不区分大小写的htaccess 301

我有以下格式的大约300个重定向

Redirect 301 /post/My-Blog-Post.aspx https://www.example.com/blog/a-new-post/

除非重定向区分大小写并且/post/my-blog-post.aspx不重定向,否则这种方法很有效.

旧URL到新URL没有模式,因此这可能必须是每个重定向的标志.

无论如何,我如何获得重定向的URL?

.htaccess http-status-code-301

6
推荐指数
1
解决办法
1万
查看次数

互联网延迟:在Chrome开发者工具网络标签中,PENDING和FROM CACHE的含义是什么

我想确认一下我是否正确理解这一点.当我在Chrome地址栏中输入"google.com"时遇到严重的延迟问题,但在我在其他浏览器中执行相同操作时却没有.我还下载了Canary,并在那里遇到同样的问题.我认为其他浏览器可能会重写URL客户端,避免前两个301和302错误.似是而非?

"待定"是否意味着该请求尚未得到满足?并且"(来自缓存)"是否意味着浏览器正在我的PC上查找该文件?

为"google.com"请求返回301错误需要21秒,然后返回302秒并将最终重定向返回到完整网址.这是否意味着处理此类请求的服务器真的负担过重?

为什么这些图片需要很长时间才能获取?59秒,还在等待?

Chrome开发者工具网络标签截屏

google-chrome latency http-status-code-301 http-status-code-302

6
推荐指数
1
解决办法
1140
查看次数

尽管配置了正确的 CORS 标头,但仍出现 301 响应“跨源请求被阻止”

我正在使用其公共 api 访问 NASA 图片,但收到此错误:

\n\n
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at\n[nasa api website] (Reason: CORS header \xe2\x80\x98Access-Control-Allow-Origin\xe2\x80\x99 missing).\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是当我检查他们的响应头时, \xe2\x80\x98Access-Control-Allow-Origin\xe2\x80\x99 存在并设置为 \'*\',在这里你可以看到它:

\n\n

响应标头:

\n\n
Access-Control-Allow-Origin *\nAge 0\nCache-Control   max-age=0, private, must-revalidate\nContent-Encoding    gzip\nContent-Type    application/json; charset=utf-8\nDate    Sat, 28 Mar 2020 14:37:13 GMT\nEtag    W/"e26hidden..."\nReferrer-Policy strict-origin-when-cross-origin\nServer  openresty\nStrict-Transport-Security   max-age=31536000; includeSubDomains\nVary    Origin\nVia https/1.1 api-umbrella (ApacheTrafficServer [cMsSf ]), 1.1 vegur\nX-Cache MISS\nX-Content-Type-Options  nosniff\nX-Download-Options  noopen\nX-Frame-Options SAMEORIGIN\nX-Permitted-Cross-Domain-Policies   none\nX-RateLimit-Limit   1000\nX-RateLimit-Remaining   999\nX-Request-Id    00c8c415-37ad-474b-bfbd-8e968d60f37f\nX-Runtime   0.125778\nX-Xss-Protection    1; mode=block\n
Run Code Online (Sandbox Code Playgroud)\n\n

请求标头:

\n\n
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\nAccept-Encoding gzip, deflate, …
Run Code Online (Sandbox Code Playgroud)

javascript xmlhttprequest cors http-status-code-301

6
推荐指数
1
解决办法
7575
查看次数