404找不到页面无法与我的.htaccess一起使用 [英] 404 not found page not working with my .htaccess

查看:100
本文介绍了404找不到页面无法与我的.htaccess一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上的.htaccess下面具有未找到的页面规则,但它似乎不起作用.有什么主意吗?

I have below .htaccess on the server with the not found page rules but it doesn't seems to work. Any idea?

RewriteEngine on
RewriteRule ^article_detail/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ article_detail.php?article_det=$2
Options +FollowSymLinks
ErrorDocument 404 http://www.example.com/main/404_not_found.html


# compress text, HTML, JavaScript, CSS, and XML

<IfModule mod_ext_filter.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

推荐答案

我假设您使用的是Apache而不是IIS;

I'm assuming you're using Apache rather than IIS;

  1. 确保已启用mod重写(您可以通过在httpd.conf文件(通常位于/conf/目录中)下面找到这一行来完成此操作您正在使用共享托管,并从该行的开头删除分号)

  1. Ensure you have mod rewrite enabled (You can do this by locating the line below in the httpd.conf file (usually within the /conf/ directory This maybe different if you're using shared hosting and removing the semi colon from the start of the line)

;LoadModule rewrite_module modules/mod_rewrite.so

找到www根目录的相关目录标记,然后将AllowOverride None更改为AllowOverride All

Find the relevant directory tag for your www root and change AllowOverride None to AllowOverride All

在根目录中创建一个.htaccess文件(如果不存在)

您需要插入类似这样的内容;

ErrorDocument 500 /errordocs/500.html

ErrorDocument 404 /errordocs/404.html

ErrorDocument 401 /errordocs/401.html

ErrorDocument 403 /errordocs/403.html

  • 您也可以执行ErrorDocument 404 http://www.yourdomain.com/errordocs/404.html而不是ErrorDocument 404 http://www.yourdomain.com/errordocs/404.html甚至只显示一条简单消息ErrorDocument 404 "Sorry can't allow you access today"

  • Instead of ErrorDocument 404 /errordocs/404.html you could also do ErrorDocument 404 http://www.yourdomain.com/errordocs/404.html or even just display a simple message ErrorDocument 404 "Sorry can't allow you access today"

如果遇到任何问题,请 Apache手册(ErrorDocument指令)应该会进一步帮助您.

If you have any trouble the Apache Manual (ErrorDocument Directive) should help you out further.

在您的情况下,请确保打开AllowOverride All,在根目录中编辑.htaccess文件,并确保可以单击错误页面的URL,如果您指定的URL没有任何内容,Apache将返回默认为404.

In your case make sure AllowOverride All is on, your editing the .htaccess file in the root and make sure you can hit the URL for the error page, if there's nothing at the URL that you specify Apache will return the default 404.

这篇关于404找不到页面无法与我的.htaccess一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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