htaccess errordocument 404 and pass url to path

后端 未结 3 1695
半阙折子戏
半阙折子戏 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:34

    On apache 2.4 and later, you can use mod-rewrite variables with ErrorDocument directive :

    ErrorDocument 404 /404.php?uri=%{REQUEST_URI}
    

    This will internally send the 404 uri to your 404.php page and you can manipulate it using the following code in 404.php

    
    

提交回复
热议问题