centos7下配置apache伪静态页

1、在etc/httpd/conf/httpd.conf下找到Include conf.modules.d/*.conf,在这句话下添加LoadModule rewrite_module modules/mod_rewrite.so;

2、在站点配置文件中添加以下配置:

     <Directory /var/www/站点目录>
           AllowOverride all
     </Directory>

3、在站点根目录下添加.htaccess文件,文件内容:

     <IfModule rewrite_module>
             RewriteEngine On
             RewriteRule  html/test([0-9]+).html$ html/test.php?Id=$1

      </IfModule>

4、重启httpd服务,systemctl restart httpd。

(说明:RewriteRule  html/test([0-9]+).html$ html/test.php?Id=$1中,html是你要设置静态页的目录,test.php是要变成静态页的页面

猜你喜欢

转载自blog.csdn.net/qooer_tech/article/details/78793020