Apache开启 .htaccess , url_rewrite ,vhost

1. 开启.htaccess支持

将 httpd.conf 中
AllowOverride None
改为
AllowOverride All

2. 开启url_rewrite模块

去掉 httpd.conf#LoadModule rewrite_module modules/mod_rewrite.so 前面的#

3. 开启vhost功能

(1) 去掉 httpd.conf#Include conf/extra/httpd-vhosts.conf 前面的#
(2) 去掉 httpd.conf#LoadModule vhost_alias_module modules/mod_vhost_alias.so 前面是#
(3) 然后去配置 conf/extra/httpd-vhosts.conf 文件中, 根据示例配置虚拟主机

4. 常用的.htaccess配置

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3. RewriteCond %{REQUEST_FILENAME} !-d
  4. RewriteCond %{REQUEST_FILENAME} !-f
  5. RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
  6. </IfModule>

5. 常用站点配置

  1. # conf/extra/httpd-vhosts.conf
  2. <VirtualHost *:80>
  3. DocumentRoot "D:\Project\Coding\phpIDE"
  4. ServerName ide
  5. ServerAlias ide
  6. <Directory "D:\Project\Coding\phpIDE">
  7. Options FollowSymLinks ExecCGI
  8. AllowOverride All
  9. Order allow,deny
  10. Allow from all
  11. Require all granted
  12. </Directory>
  13. </VirtualHost>

别忘了在hosts文件中添加 127.0.0.1 ide

文章不错, 赏你二两银子

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续努力!