2011-03-24 48 views
1

htaccess的401重定向问题
htaccess的404重定向问题

我的问题是,我的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 
+0

你的意思是301重定向,对不对? (如你的代码所示。) – nitro2k01 2011-03-24 20:30:40

+0

没有404重定向,例如,如果有一个断开的链接,我希望它们被重定向到index.htm页面,但由于addtype应用程序行我只是说“没有指定输入文件”例如[链接] http://www.cases.com/1234.htm,我需要它被重定向到index.htm – 2011-03-24 20:47:58

+0

欢迎来到Stack Overflow!重新问同样的问题在这里是不可接受的行为。如果你想引起人们对你的问题的关注,那么两天后你将被允许[放置赏金](http://stackoverflow.com/faq#bounty)。您还可以[编辑您的问题](http://stackoverflow.com/posts/5219937/edit)添加其他信息,这可能会使您的问题更易于理解和回答。 – Will 2011-03-25 13:12:34

回答

0

我不确定,但有些人使用AddType有一些冲突。下面添加了一些似乎适用于人的变体。在尝试和更改AddType之前,请将完整的文件名称放在404重定向中。

ErrorDocument 404 /index.htm 

编辑:

我只是想你的文件,我不能重现您的问题。我看着your hosting company's docs,你说得对。有一件事我确实看到他们提到的是multiple extensions,然后带你到显示的代码(见下文),你说的地方没有工作

<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

如果这些不工作,那么它可能是一些与您的托管公司。对我来说并没有太大的作用,即使我试图重现,也不能。对不起...

+0

没有这些问题解决了,就像我说的所有的工作,当我拿出 将AddType应用/ X的httpd - PHP的.html .PHP的.htm 但随后左侧导航栏中消失。如果它帮助我在verio – 2011-03-24 21:34:25

+0

上托管,只是更新了我的回复。祝你好运 – RichardW11 2011-03-24 23:45:25

+0

我认为你可以重现问题的原因是你需要指定.htm例如[链接] www.cases.com/1324.htm [链接]这就是“没有输入文件指定”。但[链接] www.cases.com/1234 [链接]的作品。这很奇怪。 – 2011-03-25 16:27:14