用htaccess打开404页面

时间:2017-12-24 22:17:41

标签: .htaccess

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

# skip rules below this for files and directories
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]


# rewrite to the physical php page
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

# otherwise, redirect to serve.php
RewriteRule ^/?$ serve.php [L]

RewriteRule ^(\w+)/?$ serve.php?id=$1 [L,QSA]
Options -Indexes

如果无法找到ID或文件,则应打开404页面。如何在这个htaccess文件中实现它?

0 个答案:

没有答案