学习目的:让url支持 www.dev.com/Public/index.html 这样的形式
php
(1)前提apache和php已经能用了。html
设置apache配置文件web
#apache2.4.9\conf\httpd.confapache
找到以下一行ide
#LoadModule rewrite_module modules/mod_rewrite.sosvn
改成(去掉# 符号表示开启(加载)此模块)学习
LoadModule rewrite_module modules/mod_rewrite.soui
<Directory
url
Options Indexes FollowSymLinkscode
AllowOverride none
中none 改成 all(容许 htaccess 重写)
AllowOverride all
让 .htaccess 支持须要省略index.php 配置以下
# .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
重点句是:RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
RewriteEngine on RewriteEngine On|Off RewriteEngine 用于开启或停用rewrite功能
(2) 仍是403 页面 www.dev.com/Public/index.html
而 www.dev.com/index.php/Public/index.html 能正常访问
<Directory />
AllowOverride all
Require all denied
</Directory>
Require all denied(拒绝全部访问)
去掉这句。再次访问,能够正确访问(但愿发现问题的人,能一块儿交流学习)
附上:vhost配置信息
<VirtualHost *:80>
DocumentRoot "D:/code/svn_yilinker/tagwebsys/"
ServerName local.tagwebsys.com
ErrorLog "logs/dummy-local.tagwebsys.com-error.log"
CustomLog "logs/dummy-local.tagwebsys.com-access.log" common
<Directory "D:/code/svn_yilinker/tagwebsys/">
Options Indexes FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>