错误301在web服务器上永久移动

Error 301Moved Permanently on web server

本文关键字:移动 服务器 web 错误      更新时间:2023-09-26

我成功地在localhost上运行了代码。但服务器上的相同代码我得到错误301永久删除Moved permanently。我使用post-request。我的代码在下面。

$(function(){
        $("#search_text").keyup(function(e){
            var sVal = $(this).val();
            $("#search").removeAttr('disabled');
            $.post('http://localhost/website/index.php/search/ajaxResults',{Search:sVal},function(data){
                             //my code here
            });
    });
});

它成功地完成了。

但在网络服务器上也一样,代码如下:

$(function(){
        $("#search_text").keyup(function(e){
            var sVal = $(this).val();
            $("#search").removeAttr('disabled');
            $.post('http://schoolanduniversity.com/index.php/search/ajaxResults',{Search:sVal},function(data){
                             //my code here
            });
    });
});

我得到错误301

这是因为这个网址:

http://schoolanduniversity.com/index.php/search/ajaxResults

重定向到此url:

http://www.schoolanduniversity.com/index.php/search/ajaxResults

schoolanduniversity.com的DNS配置就是重定向到www.schoolanduniversity.com

如果你改变你的网址,把www放在前面,它应该可以

error code 301不是一个错误,它更像是一个警告,就像

您正在尝试访问thispage.com,但服务器已移动到该page.com,请下次使用该page.com

有关更多信息,请查看此处:HTTP/1.1:状态代码定义#错误代码301