1.ports安装apache2
2.安装后查看/usr/local/etc/apache22/httpd.conf中是否有 LoadModule rewrite_module libexec/apache22/mod_rewrite.so 没有就重装apache2,安装时候选mod_rewrite
3.编辑 /usr/local/etc/apache22/Includes/httpd-vhost.conf ee /usr/local/etc/apache22/Includes/httpd-vhost.conf
4.在相应的虚拟目录中加入
<IfModule rewrite_module> # 这里要注意的是不同.c格式 RewriteEngine On #RewriteLog "/var/log/rewrite_log" #RewriteLogLevel 10 报错等级 > 9 就是所有 RewriteRule ^(.*)/html_(.*)/.html$ $1/html/buy.php?pid=$2 </IfModule>
5.apachectl stop
6.apachectl start