工作中用到伪静态,本机工作的环境是windows的,远程服务器的是Linux的;windows用的是apache,linux用的是nginx。
apache 的步骤:
1:在conf目录下httpd.conf中找到LoadModule rewrite_module modules/mod_rewrite.so这句,去掉前边的注释符号“#”,或添加这句。
2:允许在任何目录中使用“.htaccess”文件,将“AllowOverride”改成“All”(默认为“None”):在Windows系统下不能直接建立“.htaccess”文件,可以在命令行下使用“echo a> .htaccess”建立,然后使用记事本编辑。
3:RewriteEngine on 开启Rewrite模块
4:在.htaccess文件编写规则
RewriteEngine On
RewriteBase /
RewriteRule index.html$ index.php
RewriteRule space(\d+).html$ index.php?action=space&uid=$1
RewriteRule service.html$ index.php?action=service
5:重启apache