查看: 7472|回复: 0
打印 上一主题 下一主题

ZendFramework入门配置mod_rewrite和.htaccess

[复制链接]
跳转到指定楼层
1#
发表于 2009-7-8 13:59:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
本帖最后由 七月十五 于 2009-5-16 13:30 编辑

这几天有些人一直问我如何配置Zend Framework,应大家的要求,我写了这个.由于自身水平有限,写得不好,还请大家凑合着吧!

1.启用Apache的mod_rewrite模块.

2.让.htaccess生效.(这点很多人没注意) 指令的生效

.htaccess文件中的配置指令作用于.htaccess文件所在的目录及其所有子目录, 但是,很重要需要记住的是,其更高级的目录也可能会有.htaccess文件, 而指令是按查找顺序依次生效,所以, 一个特定目录下的.htaccess文件中的指令可能会覆盖其更高级目录中的 .htaccess文件的指令,即, 子目录中的指令会覆盖更高级目录或者主服务器配置文件中的指令。



例如:



目录/www/htdocs/example1中的.htaccess文件有如下内容:



Options +ExecCGI



(注意: 必须设置"AllowOverride Options"以允许在.htaccess文件中使用 "Options"指令。)



在目录/www/htdocs/example1/example2中的.htaccess文件有如下内容:



Options Includes



由于第二个.htaccess文件的存在,/www/htdocs/example1/example2中 的CGI执行是不允许的,而只允许Options Includes,它完全覆盖了之前的设置。
复制代码我的做法把httpd.conf里面的"Options"指令 <Directory "D:/apche/Apache2/htdocs">



#

# Possible values for the Options directive are "None", "All",

# or any combination of:

#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

#

# Note that "MultiViews" must be named *explicitly* --- "Options All"

# doesn't give it to you.

#

# The Options directive is both complicated and important.  Please see

# http://httpd.apache.org/docs-2.0/mod/core.html#options

# for more information.

#

    Options FollowSymLinks

    AllowOverride All



#

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

#   Options FileInfo AuthConfig Limit

#

    AllowOverride All



#

# Controls who can get stuff from this server.

#

    Order allow,deny

    Allow from All



</Directory>
复制代码看.htaccess是否可以用 .htaccess内容



RewriteEngine on

RewriteRule !\.(js|ico|gif|jpg|png|css|swf)$ index.php

php_value include_path "./library"
复制代码注意: 这里的.htaccess在windows无法直接建立.我个人是先建立33.htaccess然后把leaftp打开.找到本地的33.htaccess,重命名位.htaccess就可以了。哈。.

5.测试下.htaccess是否可以用 打开本地的http://localhost/  随便打入http://localhost/33  看会不会转到http://localhost/ 如果不会说明你的.htaccess没有生效.

4.下载Zend Framework   http://framework.zend.com/download

(解压后把library文件夹放在网站的根目录下)


注意问题:.htaccess一定要让它生效...

补充问题:  .htaccess里面的php_value include_path 在linux下有的无法使用的。可以通过set_include_path()函数来设置(放在require_once()之前)。
如:index.php里面要这样:
set_include_path('./library');
include 'Zend';
或者你也可以直接在php.ini里面设置.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表