404找不到页面无法与我的.htaccess一起使用

编程入门 行业动态 更新时间:2024-10-25 12:17:06
本文介绍了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 www.example/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;

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

  • 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 www.yourdomain/errordocs/404.html而不是ErrorDocument 404 www.yourdomain/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 www.yourdomain/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一起使用

    本文发布于:2023-11-01 17:42:33,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1549984.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:找不到   页面   htaccess

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!