本地wamp实现虚拟主机后,我把自己的站放进去就出现了500错误看日志看到
.htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration不支持伪静态,那么我来分享一下本地wamp实现伪静态:
第一步:找到Apache安装目录下httpd.conf这个文件,搜索找到,“LoadModule rewrite_module modules/mod_rewrite.so”,找到这一行,去掉前面的“#”;
第二步:
# 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
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
找到“AllowOverride None”改为“AllowOverride All”.;
第三步:重启apache
第四步:新建.haccess文件,放在当前网站根目录下,在.haccess文件中写伪静态规则,看示例
RewriteEngine on
RewriteBase /
RewriteRule ^article\.html$ /article.php
RewriteRule ^article\_(+)\.html$ /article.php?page=$1
到此就完成了
备注:(1)出现404错误为伪静态规则写错.