The requested URL /site/login was not found on this server.

Apache + Yii 配置本地的后台项目,配置虚拟主机:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "F:\web\trunk\proj\backend\web"
    ServerName www.proj.com
    ErrorLog "logs/cps-error.log"
    CustomLog "logs/cps-access.log" common
	<Directory "F:\web\trunk\proj\backend\web">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
                AllowOverride All
		Order allow,deny
		Allow from all
                Require all granted
       </Directory>
</VirtualHost>

浏览器执行:www.proj.com,报错:
Not Found
The requested URL /site/login was not found on this server.  
解决方法:F:\web\trunk\proj\backend\web目录下添加.htaccess文件。 
. htaccess 是Apache服务器配置文件和httpd.conf相同作用。里边存放Apache服务器配置的相关指令
.htaccess 内容:

RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php

.htaccess

.htaccess 的基本作用:
1. URL重写、自定义错误页面
2. MIME类型配置
3. 访问权限控制等
4. 主要体现在伪静态的应用
5. 图片防盗链
6. 自定义404错误页面
7. 阻止/允许特定IP/IP段
8. 目录浏览与主页
9. 禁止访问指定文件类型
10. 文件密码保护 
启用.htaccess
1. htppd.conf配置启用AllowOverride
<Directory>
     Options FollowSymLinks
     AllowOverride All
</Directory>
2. httpd.conf 打开mod_rewrite机制
在httpd.conf 查找mod_rewrite 去掉LoadModule rewrite_module modules/mod_rewrite.so前边的#

287 人浏览过

发表评论

邮箱地址不会被公开。 必填项已用*标注