Zend FrameWork mod_rewrite已启用,但网址仍然无效 - wamp server 2.1?

时间:2012-01-28 11:16:34

标签: zend-framework wampserver

我启用了mod_rewrite并在httpd.conf中有以下内容:

<Directory />
  Options FollowSymLinks
  AllowOverride all
  Order allow,deny
  Allow from all
</Directory>

我已设置别名以指向项目127.0.0.1/whatford /

中的公用文件夹

但是我仍然需要在我的url前面加上index.php来访问其他控制器/视图example = 127.0.0.1/whatford/index.php/contact - 而不是127.0.0.1/whatford/contact?

感谢任何帮助

2 个答案:

答案 0 :(得分:3)

尝试使用虚拟主机。

以下是您可以根据域名test.local

尝试的设置

因此,如果您通过添加域名来使用Windows更新C:\ Windows \ System32 \ drivers \ etc \ hosts:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost 
    127.0.0.1       test.local

如果您在Windows下使用Apache,请更新httpd-vhosts.conf文件(确保在DocumentRoot和Directory下输入正确的文件夹名称):

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
# NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "C:\www\yourProjectApplicationFolder\public"
    ServerName test.local
    <Directory C:\www\yourProjectApplicationFolder\public>
    Options Indexes FollowSymLinks
    AllowOverride All
    allow from all
    </Directory>
</VirtualHost>

您需要确保取消注释

#Include conf/extra/httpd-vhosts.conf
在Apache httpd.conf文件中

行,所以它看起来像这样:

Include conf/extra/httpd-vhosts.conf

然后重启Apache并转到http://test.local,你应该有你的起始页。

如果这对您有用或者您遇到任何其他问题,请告诉我。

干杯,

戴夫

答案 1 :(得分:0)

我用这个:
$_SERVER["REQUEST_URI"] = str_replace('index.php','',$_SERVER["REQUEST_URI"]);
添加到我的index.php的顶部以删除url中的index.php。

同时查看此Vhost in Zend Server,以及此帖后,即使您没有设置完整的虚拟主机,也可以确保您的Apache设置对于ZF是正确的。