學習目的:讓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>