tp3.2.3 rewrite apache 配置

时间:2022-10-27 14:21:40

本配置建立于 在fastcgi模式下

1. 开启rewrite拓展

# vi apache/conf/httpd.conf

#找到rewrite_module, 并把#号去除,保存
2.vi apache/conf/vhosts.conf
#最下面添加一个域名映射目录关系

<VirtualHost *:80>
    DocumentRoot "G:\study\WWW\tp3"
    ServerName www.tp3.com
    ServerAlias tp3.com
  <Directory "G:\study\WWW\tp3">
      Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
  </Directory>
</VirtualHost>

3.重启apache

4.在thinkphp根目录下找到.htaccess(没有则新建)内容如下:

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
5. 修改.hosts文件 加上 tp3.com 127.0.0.1, 重启apache,并浏览器访问 tp3.com/Home/Index/index