很多程序都会用到伪静态。在这里统一记录下操作的方法。
Apache伪静态配置:
A) PHP配置
vim /etc/php.ini cgi.fix_pathinfo = 1 #将注释去掉
B) apache配置
vim /etc/httpd/conf/httpd.conf LoadModule rewrite_module modules/mod_rewrite.so #将该句注解去掉。 <Directory /> Options FollowSymLinks AllowOverride None </Directory> #中把AllowOverride的None改为All service httpd restart #重启apache
Nginx伪静态配置
vim /etc/nginx/conf.d/default.conf location / { root /var/www/html; index index.html index.htm index.php; } #在这里面加入各自程序的伪静态规则,如thinkphp的伪静态规则如下 location / { root /var/www/html; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } service nginx restart #重启nginx
按照这样的方式,伪静态就生效了!