1.开启rewrite_module模块 参考路径 D:\PC_webserver\apache\conf\httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
2.搜索Directory 找到对应的目录。红色的字为网站目录 加粗为修改部分
<Directory "D:/PC_webserver/phproot">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
还有一个地方
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
3.根目录建立.htaccess文件 以下是内容 然后重启apache 第一个404是状态码
参考资料 http://www.tuicool.com/articles/NFfUBj3
ErrorDocument 404 /404.html
来源:https://www.cnblogs.com/xxx91hx/p/5501667.html