标签: http-status-code-404

HttpWebResponse返回404错误

如何让Httpwebresponse忽略404错误并继续使用它?它比在输入中查找异常更容易,因为在发生这种情况时非常罕见.

c# httpwebresponse http-status-code-404

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

Wordpress:URL错误404,但页面存在

我把我的wordpress(3.0)博客移到了我的专用服务器上.

只有一件事是破碎的:

如果我在worpress中设置url

http://wwww.example.com/page?id=3
Run Code Online (Sandbox Code Playgroud)

页面正确显示

如果我将URL设置为:

http://wwww.example.com/about/
http://www.example.com/services/
Run Code Online (Sandbox Code Playgroud)

它最终得到404找不到的页面!

如果它有帮助,这是我的虚拟主机:

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerName www.example.fr

    DocumentRoot /var/www/example
    <Directory /var/www/example>
            Options -Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>


    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access-example.log combined
    ErrorLog /var/log/apache2/error-example.log
    ServerSignature Off
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

谢谢

wordpress url-rewriting url-routing http-status-code-404

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

Magento多语言 - 404中语言重复的双重更改(或如何更改商店内的语言而不是视图)

我有一个magento安装问题.我用过Magento ver.1.5.0.1,社区版开发本网站http://cissmarket.com/.

当我将语言从EU版本更改为法语并在此之后更改为德语时,会出现问题.对法语的更改是可以的,但是当在同一页面中我更改为德语时,我收到404错误.此外,这是Google网站管理员工具中的代404错误,当我尝试使用此链接并将其粘贴到浏览器中时,它也会出现404错误.我在Google网站管理员工具中有大约50种产品和~550 404错误.我知道问题来自我所描述的.

此外,我有一个SEO问题,因为我有这个页面用法语:

http://cissmarket.com/de/cartouches-refilables.html

当我切换到网站的德语版本时,它会带我到这个链接

http://cissmarket.com/de/cartouches-refilables.html?___from_store=fr(如果我现在尝试切换到英国,我会得到上面提到的404)

而不是去这一个:

http://cissmarket.com/de/nachfullpatronen.html

在关于magento的类别中切换商店时已经检查了这个404错误但是它与我的问题无关.

关于设置:

  • 我使用缓存服务,并且我确实索引了所有内容.
  • 我尝试访问的产品或类别可用,并为所有语言设置为活动状态.
  • 系统>常规> Web> URL选项>将商店代码添加到Urls设置为yes.
  • 系统>常规> Web>搜索引擎优化>使用Web服务器重写设置为yes.
  • 除了系统本身制作的文件外,没有对.htaccess文件进行任何其他更改.

因此得出结论:问题是当我从一个页面切换到另一个页面时,语言的2次成功更改和错误的URL地址给出的404.

任何建议,将不胜感激.

更新:尝试了这个http://www.activo.com/how-to-avoid-the-___from_store-query-parameter-when-switching-store-views-in-magento但是在第一次语言更改时会产生404

编辑#1:

发现问题:文件languages.phtml包含此代码<?php echo str_replace ("/fr/","/de/",$_lang->getCurrentUrl()); ?>,实际上只根据相应的翻译替换了语言代码而不是整个URL.

所以适用于此

http://cissmarket.com/fr/cartouches-refilables.html

它会回来

http://cissmarket.com/de/cartouches-refilables.html

那么有谁知道如何获得商店中其他语言的当前页面的相应URL?

编辑#2(使用@Vinai解决方案):

它适用于产品页面但不适用于该类别.

url multilingual seo magento http-status-code-404

4
推荐指数
1
解决办法
6355
查看次数

似乎无法将404和Location标头一起发送

我试图在数据库结果为空(这是产品页面)时发送两者.

我现在使用的代码,有效:

    header("Status: 404 Not Found");
    include_once("404.html");
    exit;
Run Code Online (Sandbox Code Playgroud)

我最初尝试过的代码不起作用:

    header("Status: 404 Not Found");
    header("Location: 404.html");
    exit;
Run Code Online (Sandbox Code Playgroud)

使用后面的代码,我可以使用其中之一,但不能同时使用两者.换句话说,我可以发送404标头并看到它显示在Wireshark中,或者我可以发送Location标头并重定向,但是如果我尝试发送两者,则只会发送404并且Location头也不会重定向.

我已经用可行的解决方案解决了问题,但我想知道为什么会这样.

带有FastCGI的Linux上的PHP 5.2.

谢谢.

php header http-headers http-status-code-404

4
推荐指数
1
解决办法
3262
查看次数

找不到ASP.NET MVC 3 HttpPost操作方法

我有一个简单的表单,发布到一个HttpPost动作方法,返回其相应的视图.我的问题是我收到了404 Not Found错误.奇怪的是,如果我将action方法和action方法的属性更改为a GET,那么它就可以工作并显示TestMethod视图.

似乎我错过了使用的东西POST,但我在其他控制器中的帖子工作正常(例如帐户登录和注册).请注意,该AllowAnonymous属性是一个自定义属性,可以指定允许匿名访问的控制器或操作,而不是指定(通过Authorizeattr)需要授权的控制器或操作.我想没有什么是不可能的,但我认为这与我的问题没有任何关系.什么错误的想法?

形成:

@using (Html.BeginForm("TestMethod", "Test", FormMethod.Post, new { @id = "testForm" })) {
    <fieldset>
        <legend>Test Form</legend>
        <input type="submit" value="Submit" />
    </fieldset>
}
Run Code Online (Sandbox Code Playgroud)

控制器行动:

[AllowAnonymous]
[HttpPost]
public ActionResult TestMethod() {
    return View();
}
Run Code Online (Sandbox Code Playgroud)

视图:

<h2>TestMethod</h2>
<p>HttpPost method was successful.</p>
Run Code Online (Sandbox Code Playgroud)

从Global.asax.cs注册路由方法:

public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("favicon.ico");
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        // About
        routes.MapRoute(
            "About", // Route name
            "about", // URL with parameters
            new { controller = "Home", action …
Run Code Online (Sandbox Code Playgroud)

post url-rewriting http-status-code-404 razor asp.net-mvc-3

4
推荐指数
1
解决办法
6204
查看次数

为什么我的自定义404错误处理程序在部署到Web服务器后不起作用

我按照这篇文章创建了一个全局错误处理程序.我自己添加了处理404错误.但是,当我在本地测试时它工作正常但是一旦部署到Web服务器,我的自定义消息就不再显示了.相反,默认丑陋的显示.

在远程调试中,我可以跟踪执行情况,它确实可以实现我的自定义404错误操作,但不知何故,IIS在某些时候接管了.

在我的Global.asax.cs中,我有:

protected void Application_Error()
{
    var exception = Server.GetLastError();
    var httpException = exception as HttpException;

    Response.Clear();
    Server.ClearError();

    var routeData = new RouteData();
    routeData.Values["controller"] = "Error";
    routeData.Values["action"] = "General";
    routeData.Values["exception"] = exception;

    Response.StatusCode = 500;

    if (httpException != null)
    {
        Response.StatusCode = httpException.GetHttpCode();

        switch (Response.StatusCode)
        {
            case 403:
                routeData.Values["action"] = "Http403";
                break;
            case 404:
                routeData.Values["action"] = "Http404";
                break;
        }
    }

    IController errorController = new ErrorController();
    var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
    errorController.Execute(rc);
}
Run Code Online (Sandbox Code Playgroud)

然后在我的ErrorHandler.cs中,我有:

public ActionResult …
Run Code Online (Sandbox Code Playgroud)

asp.net error-handling asp.net-mvc http-status-code-404 asp.net-mvc-4

4
推荐指数
1
解决办法
1240
查看次数

OPTIONS 预检请求未到达 IIS 托管服务

我有一个本地主机网站和一个 IIS(7.5) 托管的 WCF 服务,它是这样实现的,并附加了一个 Visual Studio 调试器。每当我向我的服务发出 CORS 请求时,我都会收到以下 404 响应以及标准的 ASP.Net 错误页面:

OPTIONS http://192.168.200.44/api/values HTTP/1.1
Host: 192.168.200.44
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Origin: http://localhost:51946
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

Response >>
HTTP/1.1 404 Not Found
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Thu, 26 Sep 2013 09:38:49 GMT
Content-Length: 1245
Run Code Online (Sandbox Code Playgroud)

Originally I was receiving erroneous 200 messages which …

iis wcf iis-7 cors http-status-code-404

4
推荐指数
1
解决办法
4547
查看次数

Web Api 2:带内容的NotFound()?

我有以下资源用于返回特定的公司信息:

[HttpGet]
[Route("{companyId:Guid}")]
public IHttpActionResult Get(Guid companyId)
{
    var company = CompanyRepository.Find(companyId);

    if (company == null)
    {
        return NotFound();
    }
    else
    {
        var responseModel = new CompanyResponseModel()
        {
            CompanyId = company.Id,
            Name = company.Name
        };

        return Ok(responseModel);
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么我们不能将内容包含在NotFound()通话中?

例如,我想包含一个错误响应模型,其中包含"公司ID不存在"的消息.

这可能是针对RESTful设计的吗?

asp.net rest api-design http-status-code-404 asp.net-web-api2

4
推荐指数
1
解决办法
1980
查看次数

未找到主页的PythonAnywhere Django 404页面

我知道有类似这样的帖子.我已经回顾了它,它与我在Pythonanywhere.com上遇到的情况完全不同

我正在尝试将我通过tangowithdjango.com完成的rango教程项目部署到Pythonanywhere.com上.当我尝试打开网站(url是ragzputin.pythonanywhere.com)时,我得到这个页面:

在此输入图像描述

这是我的项目的urls.py文件:

from django.conf.urls.defaults import *
from django.conf import settings

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',

    url(r'^rango/', include('rango.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

if settings.DEBUG:
urlpatterns += patterns(
    'django.views.static',
    (r'media/(?P<path>.*)',
    'serve',
     {'document_root': settings.MEDIA_ROOT}), )
Run Code Online (Sandbox Code Playgroud)

如果你们需要一些额外的信息,这里是我的应用程序urls.py(应用程序名称是rango):

from django.conf.urls import patterns, url
from rango import views

urlpatterns = patterns('',
    url(r'^$', views.index, name="index"),
    url(r'^about/$', views.about, name="about"),
    url(r'^add_category/$', views.add_category, name="add_category"),
    url(r'^category/(?P<category_name_url>\w+)/add_page/$', views.add_page,   name="add_page"),
    url(r'^category/(?P<category_name_url>\w+)/$', views.category, name="category"),
    url(r'^register/$', views.register, name="register"),
    url(r'^login/$', views.user_login, …
Run Code Online (Sandbox Code Playgroud)

python django http-status-code-404 pythonanywhere

4
推荐指数
1
解决办法
925
查看次数

弹出注销时出错404

我正在尝试使用spring security v.4为我的应用添加登录功能.登录工作正常,但当我尝试注销时出现错误404.Spring Security参考说默认注销URL是/ logout.我的应用程序部署在/ app URL下,我尝试按照URL的localhost:8080/app/logout和localhost:8080/app/json/logout.我在堆栈上发现了一些类似的问题,但它们是关于使用CSRF保护并且我没有使用它的情况.这是我的web.xml文件的一部分

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/json-servlet.xml,
        /WEB-INF/applicationContext.xml</param-value>
</context-param>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>json</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>json</servlet-name>
    <url-pattern>/json/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

和我的json-servlet.xml在哪里是spring安全配置:

    <context:component-scan base-package="test" />
<mvc:annotation-driven />

<security:http>
    <security:intercept-url pattern="/**" access="hasRole('USER')" />
    <security:form-login />
    <security:logout />
</security:http>

<security:authentication-manager>
    <security:authentication-provider>
        <security:user-service>
            <security:user name="test" password="1" authorities="ROLE_USER, ROLE_ADMIN" />
        </security:user-service>
    </security:authentication-provider>
</security:authentication-manager>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

spring spring-security logout http-status-code-404

4
推荐指数
1
解决办法
5083
查看次数