标签: http-status-code-404

使用URL Rewrite和404.aspx时回发问题

我在我的网站上使用URL重写来获取以下URL:
http://mysite.com/users/john
而不是
http://mysite.com/index.aspx?user=john

要使用IIS6实现这种无扩展的重写并且无法访问托管服务器,我使用"404-approach".当服务器找不到请求时,执行映射的404页面,因为这是一个aspx页面,可以执行重写(我可以使用托管服务上的控制面板设置404映射).

这是Global.asax中的代码:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    string url = HttpContext.Current.Request.Url.AbsolutePath;
    if (url.Contains("404.aspx"))
    {
        string[] urlInfo404 = Request.Url.Query.ToString().Split(';');
        if (urlInfo404.Length > 1)
        {
            string requestURL = urlInfo404[1];
            if (requestURL.Contains("/users/"))
            {
                HttpContext.Current.RewritePath("~/index.aspx?user=" + GetPageID(requestURL));              
                StoreRequestURL(requestURL);
            }
            else if (requestURL.Contains("/picture/"))
            {
                HttpContext.Current.RewritePath("~/showPicture.aspx?pictureID=" + GetPageID(requestURL));
                StoreRequestURL(requestURL);
            }
        }
    }
}

private void StoreRequestURL(string url)
{
    url = url.Replace("http://", "");
    url = url.Substring(url.IndexOf("/"));
    HttpContext.Current.Items["VirtualUrl"] = url;
}

private string GetPageID(string requestURL)
{
    int idx = requestURL.LastIndexOf("/"); …
Run Code Online (Sandbox Code Playgroud)

asp.net postback url-rewriting http-status-code-404

3
推荐指数
1
解决办法
9204
查看次数

通过管理面板访问模块设置时出现Magento 404错误

所以我下载了Magento免费博客扩展,但它只支持一个博客.所以我复制了扩展,因为我在magento商店需要多个博客.我在扩展副本中更改了所有引用和调用,并能够将其作为单独的扩展安装.

但是,当我想从管理面板创建一个新帖子时,它会给我一个Magento 404错误.

如果有人可以看看,让我知道我错过了什么,我将不胜感激.

请注意我使用两个环境进行测试:

  1. 使用PHP 5.2.6,MySQL 5和Apache 2.0.59通过MAMP/WAMP(用于Mac和Windows的预打包LAMP桌面环境)本地安装Magento

  2. PHP 5.2.10,MySQL 5.x和Apache 2.x的Web服务器

在我当地的MAMP/WAMP上,我可以创建一个没有问题的博客.但是,当我从实时服务器测试它时,我不再能够创建新的博客帖子,并且重定向到创建帖子页面的管理页面会给我一个magento 404错误.

我一直在想这可能与某些服务器设置有关,但我完全不确定,如果其他人可以为我调查,我会很感激.

谢谢.

程序员

php module magento http-status-code-404

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

如何配置IIS以使用我的自定义内容提供404响应?

这个问题与此有关,希望能更好地表达.

我想从ASP.NET MVC提供自定义404页面.我有路由处理程序和所有基础结构设置,以确保单个操作处理不存在的路由:

public ActionResult Handle404()
{
    Response.StatusCode = 404;
    return View("NotFound");
}
Run Code Online (Sandbox Code Playgroud)

问题:当我在返回内容之前将Response.StatusCode设置为404时,IIS会回送自己的内容(某些预定义消息).

在VS开发Web服务器上,这可以按预期工作 - 当我的内容(NotFound视图)被提供时,HTTP响应的状态代码是404 .

我相信当IIS处理管道看到应用程序返回404时,它只是用自己的响应替换整个响应.

IIS中的哪些设置会影响此行为?

我无法访问IIS安装,因此我无法对此进行调查 - 但是,如果我知道确切需要更改的内容,我可以要求托管服务提供商为我调整配置.

asp.net iis asp.net-mvc http-status-code-404

3
推荐指数
1
解决办法
1004
查看次数

如何从wcf服务中找不到404?

曾经,为了完全控制HTTP消息的头部/主体 - 我使用Message类.例如,要返回一些XML,我会调用

  public Message ShowRunResults()
  {
    // some [OperationContract] implementation
    webContext.CreateTextResponse(result.ToString(), "application/xml", Encoding.ASCII);
  }
Run Code Online (Sandbox Code Playgroud)

问题是如何返回404未找到或其他HTTP代码?非常感谢

.net wcf http-status-code-404

3
推荐指数
1
解决办法
2635
查看次数

Umbraco自定义404错误页面不起作用

嘿伙计们正在使用Umbraco 4.7和我的服务器是IIS7想知道什么是不适合我.我基本上想要制作一个自定义错误页面(404),我尝试的一切都不起作用,检查论坛,但它仍然显示相同的问题.

我编辑了我的umbracoSettings.config

<errors>
   <!-- the id of the page that should be shown if the page is not found -->
   <!-- <errorPage culture="default">1647</errorPage> -->
   <!-- <errorPage culture="en-US">1647</errorPage> -->
   <error404>1647</error404>
</errors>
Run Code Online (Sandbox Code Playgroud)

此外,我已经考虑过将此添加到web.config文件中.

<httpErrors errorMode="Custom" existingResponse="Replace">
   <remove statusCode="404" subStatusCode="-1" />
   <error statusCode="404" prefixLanguageFilePath="" path="/error.aspx" responseMode="ExecuteURL" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感谢.我是IIS的完整新手和涉及网络设置的任何事情.

谢谢保罗

redirect umbraco http-status-code-404

3
推荐指数
2
解决办法
7108
查看次数

无法在Django Admin中打开已保存的文件

我可以通过Django admin在我的一个模型中成功保存文件但是无法打开文件.这是我的模型:

class Answer (models.Model):
    answer = models.CharField(max_length=1000)
    attach_file = models.FileField(upload_to='Attachments', blank=True)
Run Code Online (Sandbox Code Playgroud)

我没有触及设置文件,据我所知它应该使用默认值:

MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = ''
Run Code Online (Sandbox Code Playgroud)

我在admin.py中注册了模型,然后我就可以浏览文件并保存了.当试图打开该文件时,我得到:

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/businessui/answer/1/Attachments/outlook.png/
answer object with primary key u'1/Attachments/outlook.png' does not exist.
Run Code Online (Sandbox Code Playgroud)

有人可以指出我在这里缺少什么能够在我的开发机器上本地打开保存的文件?

django admin file http-status-code-404

3
推荐指数
1
解决办法
1574
查看次数

尝试运行servlet时出现HTTP状态404错误

我有一个问题,我正在尝试运行我的简单servlet,Hello.java.我在eclipse中创建它,然后将文件放在文件webapps/ServletTest/WEB-INF/classes夹中并编译它,Hello.class在同一文件夹中创建文件.然后我修改了我的web.xml文件以映射servlet并尝试通过以下地址运行它

http://localhost:8080/ServletTest/Hello
Run Code Online (Sandbox Code Playgroud)

但是,这不起作用,给出以下错误

HTTP状态404 -

类型状态报告

信息

description请求的资源不可用.Apache Tomcat/7.0.42

web.xml文件中的映射如下所示:

<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>Main.Hello</servlet-class>
</servlet>  

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

servlet的代码:

package Main;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/Hello")
public class Hello extends HttpServlet {
private static final long serialVersionUID = 1L;
public Hello() {
super();
 }

protected void doGet(HttpServletRequest request, HttpServletResponse                   

response)  throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    String path = request.getContextPath();
    String ip = …
Run Code Online (Sandbox Code Playgroud)

java eclipse tomcat servlets http-status-code-404

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

将所有Apache 2.2 403禁止重定向到404 Not Found

我需要将Apache 2.2服务器上的所有请求重定向到任何未找到404的目录.

例如:

  • /xyz或者/xyz/抛出403 - >重定向到404
  • /xyz/sometext.txt 正常返回.

环顾四周,我发现了这篇文章:

问题重定向403禁止404找不到

RedirectMatch 404 ^/include(/?|/.*)$

/include 404 (instead of 403)
/include/ 404
/include/config.inc 404 (instead of 403)
Run Code Online (Sandbox Code Playgroud)

但是,最后一种情况也返回404.此外,它只影响/ include /目录,我正在寻找更多的任何禁止目录.到目前为止,我有:

RedirectMatch 404 ^[\/[\w+]]+\/$
Run Code Online (Sandbox Code Playgroud)

任何人都知道如何实现这一目标?谢谢,

apache .htaccess http-status-code-403 http-status-code-404

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

从404上的RESTful Spring API返回错误JSON(不明确的@ExceptionHandler)

我正在使用Spring(4.0.4)MVC来构建RESTful API.我需要返回一个ResponseEntity,其中包含一个错误的JSON表示,其中http状态为404.

但是,当我发出导致404的请求而不是看到错误JSON时,我得到以下输出:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /project/api/resource/100 was not found on this server.</p>
<p>Additionally, a 503 Service Temporarily Unavailable
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
Run Code Online (Sandbox Code Playgroud)

从这个stackoverflow帖子,我发现我可以通过在我的web.xml中包含以下参数来防止发送此错误页面代替错误

<init-param>
    <param-name>throwExceptionIfNoHandlerFound</param-name>
    <param-value>true</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)

并使用类似于此的全局建议:

@ControllerAdvice
public class MyExceptionHandler extends ResponseEntityExceptionHandler {

    @ExceptionHandler(NoHandlerFoundException.class)
    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    @ResponseBody
    public ResponseEntity<ErrorResponse> requestHandlingNoHandlerFound(HttpServletRequest req,
            NoHandlerFoundException ex) {

        ErrorResponse errorResponse = new ErrorResponse();
        errorResponse.setText("error response"); …
Run Code Online (Sandbox Code Playgroud)

rest spring exception-handling http-status-code-404

3
推荐指数
1
解决办法
5676
查看次数

未找到改造404 Web API

我有一个Web API和一个应用程序。所以我想注册一个应用程序,但是我遇到了问题。我用天蓝色。有我的registerapi(接口)

@FormUrlEncoded
@POST("/application/json")
public void insertUser(
        @Field("Username") String Username,
        @Field("Password") String Password,
        @Field("Email") String Email,
        Callback<Response> callback);
Run Code Online (Sandbox Code Playgroud)

和我的mainactivty.java页面

public class MainActivity extends AppCompatActivity {

private EditText editTextUsername;
private EditText editTextPassword;
private EditText editTextEmail;
private Button buttonRegister;
final public static String ROOT_URL = "http://bsapmusic.azurewebsites.net/api/music/register";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    editTextUsername = (EditText) findViewById(R.id.etusername);
    editTextPassword = (EditText) findViewById(R.id.etpassword);
    editTextEmail = (EditText) findViewById(R.id.etmail);
    buttonRegister = (Button) findViewById(R.id.btnkayit);
    buttonRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            insertUser();
        }
    }); …
Run Code Online (Sandbox Code Playgroud)

android azure http-status-code-404 retrofit

3
推荐指数
1
解决办法
5822
查看次数