htaccess 404重定向问题

发布于 2024-10-26 04:52:09 字数 716 浏览 1 评论 0原文

htaccess 401 重定向问题

我的问题是我的 404 重定向到我的 index.htm 文件不起作用。我可以让它工作的唯一方法是删除下面的 addtype 应用程序行,但我需要它来包含网站上的左侧导航。任何帮助都会非常感谢。

ErrorDocument 404 /

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule .* products/noimage.jpg [L]

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^cases.com [NC]
RewriteRule ^(.*)$ http://www.cases.com/$1 [L,R=301]


RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# Rewrite Rule for blog.cases.com
RewriteCond %{HTTP_HOST} blog.cases.com$
RewriteCond %{REQUEST_URI} !blog/
RewriteRule ^(.*)$ blog/$1

AddType application/x-httpd-php .html .php .htm

htaccess 401 redirect problem

My problem is that my 404 redirect to my index.htm file is not working. The only way I can get it to work is by removing the addtype application line below, but I need this for an included left navigation on the site. Any help would be great thank you.

ErrorDocument 404 /

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule .* products/noimage.jpg [L]

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^cases.com [NC]
RewriteRule ^(.*)$ http://www.cases.com/$1 [L,R=301]


RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# Rewrite Rule for blog.cases.com
RewriteCond %{HTTP_HOST} blog.cases.com$
RewriteCond %{REQUEST_URI} !blog/
RewriteRule ^(.*)$ blog/$1

AddType application/x-httpd-php .html .php .htm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妥活 2024-11-02 04:52:09

我不确定,但其他一些人使用 AddType 时遇到了一些冲突。下面添加了一些似乎对人们有用的变体。在尝试更改 AddType 之前,请将完整的文件名放入 404 重定向中。

ErrorDocument 404 /index.htm

编辑:

我刚刚尝试了您的文件,但无法重现您的问题。我查看了您的托管公司的文档,您的说法是正确的。我看到他们提到的一件事是多个扩展,并且然后带您到一个显示您所说不起作用的代码(如下)的地方

<FilesMatch "\.(php|htm|html)$">
SetHandler application/x-httpd-php
</FilesMatch>

他们确实在文档中显示了列出的完整域,并特别提到“.html 文件的文件名”,如下所示。

Custom Error Messages

Add the following to the .htaccess file: 

ErrorDocument 404 http://forexample-domain.com/error.html


After "ErrorDocument", specify the error code, followed by a space, and then the path and filename of the .html file you would like to be displayed when the specified error is generated.

来源:http://support.verio.com/documents/view_article.cfm?doc_id =3624

如果这些不起作用,则可能是您的托管公司的问题。从那以后对我来说并没有多大用处,即使我尝试复制,也无法复制。对不起...

I am not sure but some others had some conflicts using the AddType. Some variations that seemed to work for people are added below. Before trying and changing the AddType, put the complete file name in the 404 redirect.

ErrorDocument 404 /index.htm

EDIT:

I just tried your file, and I can't reproduce your issue. I looked at your hosting company's docs and you have it correct. The one thing I do see them mention is multiple extensions, and then takes you to a place showing the code (below) which you said didn't work

<FilesMatch "\.(php|htm|html)$">
SetHandler application/x-httpd-php
</FilesMatch>

They do show in the documentation the full domain listed and specifically mention "filename of the .html file" as shown below.

Custom Error Messages

Add the following to the .htaccess file: 

ErrorDocument 404 http://forexample-domain.com/error.html


After "ErrorDocument", specify the error code, followed by a space, and then the path and filename of the .html file you would like to be displayed when the specified error is generated.

Source: http://support.verio.com/documents/view_article.cfm?doc_id=3624

If those don't work, then it probably is something with your hosting company. doesn't make to much since to me, and even if I tried to reproduce, couldn't. Sorry...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文