简体   繁体   中英

404 error htaccess not working

I'm trying to redirect a 404 error to a custom php page, 404.php.

I'm using this code in my .htaccess file but it doesn't seem to work. Can anyone point out what I might be doing wrong?

Options -Multiviews

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([a-z]+)/([a-z\-]+)$ /$1/$2.php 
RewriteRule ^s/([^/]*)$ /s.php?share=$1 [L]

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^mywebsite.com [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorDocument 404 /404.php

Put ErrorDocument line on top of everything.

And: a server restart is needed afaik in order to re-read .htaccess and apply any changes in there (reload will not work).

Did you restart your server?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM