htaccess errordocument 404 and pass url to path

后端 未结 3 1701
半阙折子戏
半阙折子戏 2021-01-22 05:15

How can I pass the 404\'d URL to my 404.html page using .htaccess

For example, if I visit an invalid page: /user/123

RewriteEng         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-22 05:39

    ErrorDocument is not part of mod_rewrite and that is invalid. Is this what your looking for?

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    Rewriterule ^(.*) /404.php?error_path=$1 [R=301,L]
    

提交回复
热议问题