设置一个页面,拦截所有尚未存在的页面? [英] Setting up a page that will intercept all pages that do not already exist?

查看:57
本文介绍了设置一个页面,拦截所有尚未存在的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想设置我的网站,以便当一个页面的请求不存在
时,传输将被传递给我指定的某个页面。对于

实例,如果用户请求 http://mysite.com / pages / contact

不是有效的页面或目录,请求递交给
http://mysite.com/pages/display.php 或类似内容。


我想知道最好的方法是什么 - 我知道我可以使用

..htaccess文件重定向404错误,但我宁愿不给404
$ b首先是$ b错误。有更好的/其他方式吗?我似乎记得

已经阅读了另一种方式...但我似乎无法记住...


这是在LAMP环境中,并且不需要移植到Windows

或任何其他网络服务器。


任何帮助将不胜感激!


他,

-Josh

解决方案

在comp.lang.php中Joshua Beall< jb ** **@donotspam.remove.me.heraldic.us>写道:

我想知道最好的方法是什么 - 我知道我可以使用
.htaccess文件重定向404错误,但我宁愿不给404 <首先是错误。




它被称为404处理程序,但它不必返回http错误

状态。在404处理程序脚本中,您可以返回404(

默认状态)或选择执行您可能想到的任何其他操作,

就像重定向到正确的URL如果是小错别字。客户

永远不会发现它是由404处理程序处理的......


2004年12月7日星期二21 :29:00 GMT,Joshua Beall

< jb **** @ donotspam.remove.me.heraldic.us>写道:

大家好,

我想设置我的网站,以便当页面的请求不存在时,转移是而是传递给我指定的某个页面。对于
实例,如果用户请求 http://mysite.com/pages/contact 那是
不是有效的页面或目录,然后请求被交给
http://mysite.com/pages/display.php 或者类似的东西。

我想知道最好的办法是什么 - 我知道我可以使用
.htaccess文件重定向404错误,但我宁愿不首先给出404错误。有更好的/其他方式吗?我似乎记得已经阅读了另一种方式...但我似乎无法记住......

这是在LAMP环境中,不需要是便携式的到Windows
或任何其他网络服务器。

任何帮助将不胜感激!



这实际上更像一个网络服务器问题,它真的取决于在

您正在使用的网络服务器上。你提到.htaccess,所以我会假设

apache。


编辑httpd.conf文件(/etc/httpd/conf/httpd.conf


并寻找:


#ErrorDocument 404 /missing.html

取消注释并更改网址你想要什么。


重新启动服务器

-

gburnore @databasix dot com

------------------------------------------------- --------------------------

你看起来如何取决于你去哪里。

------------------------------------------------- --------------------------

Gary L. Burnore | Y?3oY3T3oY33Y?oY3T3oY3Y3T3oY3YY?3

| Y?3oY3T3oY33Y?oY3T3oY3Y3T3oY3YY?3
DataBasix | Y?3oY3T3oY33Y?oY3T3oY3Y3T3oY3YY?3

| Y?3 3 4 1 4 2 Y3T3 6 9 0 6 9 Y?3

黑色直升机维修Svcs部门|官方购买证明

=================== ========================== ===== =========================

想要一个?得到一个! http://signup.databasix.com

=== =============================================== === ======================


" Daniel Tryba" < SP ** @ tryba.invalid>在消息中写道

news:41 *********************** @ dreader3.news.xs4al l.nl ... < blockquote class =post_quotes>在comp.lang.php中Joshua Beall< jb **** @ donotspam.remove.me.heraldic.us>
写道:

我想知道这样做的最好方法是 - 我知道我可以使用
.htaccess文件重定向404错误,但我宁愿不首先给出404
错误。



它被称为404处理程序,但它不必返回http错误状态。在404处理程序脚本中,您可以返回404(
默认状态)或选择执行您可能提出的任何其他操作,例如,如果出现小错别字,则重定向到正确的URL。客户
永远不会发现它是由404处理程序处理的......




好​​的。


还有其他方法吗?这些是什么?他们是否提供某种优势?b $ b b?有没有理由不去404处理程序路线?


Hi All,

I would like to setup my site so that when a page is request that does not
exist, transfer is instead passed to a certain page that I specify. For
instance, if the user requests http://mysite.com/pages/contact and that is
not a valid page or directory, then the request is handed to
http://mysite.com/pages/display.php or something like that.

I am wondering what the best way to do this is - I know that I could use an
..htaccess file to redirect 404 errors, but I would rather not give a 404
error in the first place. Is there a better/other way? I seem to remember
having read about another way... but I can''t seem to remember...

This is in a LAMP environment, and does not need to be portable to Windows
or any other webserver.

Any help would be greatly appreciated!

His,
-Josh

解决方案

In comp.lang.php Joshua Beall <jb****@donotspam.remove.me.heraldic.us> wrote:

I am wondering what the best way to do this is - I know that I could use an
.htaccess file to redirect 404 errors, but I would rather not give a 404
error in the first place.



It''s called a 404 handler, but it doens''t have to return an http error
status. In the 404 handler script you can either return a 404 (the
default status) or choose to do anything else you might come up with,
like redirecting to the correct url in case of small typos. The client
will never find out it was handled by the 404 handler...


On Tue, 07 Dec 2004 21:29:00 GMT, "Joshua Beall"
<jb****@donotspam.remove.me.heraldic.us> wrote:

Hi All,

I would like to setup my site so that when a page is request that does not
exist, transfer is instead passed to a certain page that I specify. For
instance, if the user requests http://mysite.com/pages/contact and that is
not a valid page or directory, then the request is handed to
http://mysite.com/pages/display.php or something like that.

I am wondering what the best way to do this is - I know that I could use an
.htaccess file to redirect 404 errors, but I would rather not give a 404
error in the first place. Is there a better/other way? I seem to remember
having read about another way... but I can''t seem to remember...

This is in a LAMP environment, and does not need to be portable to Windows
or any other webserver.

Any help would be greatly appreciated!


This is really more of a webserver question and it really depends on
the webserver you''re using. You mention .htaccess, so I''ll assume
apache.

edit the httpd.conf file (/etc/httpd/conf/httpd.conf

and look for this:

#ErrorDocument 404 /missing.html
Uncomment it and change the url to what you want.

restart the server
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | Y?3oY3T3oY33Y?oY3T3oY3Y3T3oY3YY?3
| Y?3oY3T3oY33Y?oY3T3oY3Y3T3oY3YY?3
DataBasix | Y?3oY3T3oY33Y?oY3T3oY3Y3T3oY3YY?3
| Y?3 3 4 1 4 2 Y3T3 6 9 0 6 9 Y?3
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================


"Daniel Tryba" <sp**@tryba.invalid> wrote in message
news:41***********************@dreader3.news.xs4al l.nl...

In comp.lang.php Joshua Beall <jb****@donotspam.remove.me.heraldic.us>
wrote:

I am wondering what the best way to do this is - I know that I could use
an
.htaccess file to redirect 404 errors, but I would rather not give a 404
error in the first place.



It''s called a 404 handler, but it doens''t have to return an http error
status. In the 404 handler script you can either return a 404 (the
default status) or choose to do anything else you might come up with,
like redirecting to the correct url in case of small typos. The client
will never find out it was handled by the 404 handler...



Ah ok.

Are there other ways to do it? What are they? Do they provide advantages
of some sort? Is there any reason to not go the 404 handler route?


这篇关于设置一个页面,拦截所有尚未存在的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆