Zend Framework 2 .htaccess mamp pro [英] Zend Framework 2 .htaccess mamp pro
问题描述
我想开始使用 Zend Framework 2.0 .我使用 os x lion 和 mamp pro.所以一开始我用了这个http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html,我明白了zend 项目索引页,但是
I want start to work with Zend Framework 2.0 . I use os x lion and mamp pro. So to start I used this http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html all good, I see zend project index page, but
要测试您的 .htaccess 文件是否正常工作,请导航至 http://zf2-tutorial.localhost/1234 你应该看到这个:
To test that your .htaccess file is working, navigate to http://zf2-tutorial.localhost/1234 and you should see this:
如果您看到标准的 Apache 404 错误,那么您需要在继续之前修复 .htaccess 的用法.如果您将 IIS 与 URL 重写模块一起使用,请导入以下内容:RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*$ index.php [NC,L]
If you see a standard Apache 404 error, then you need to fix .htaccess usage before continuing. If you’re are using IIS with the URL Rewrite Module, import the following: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*$ index.php [NC,L]
所以我这样做,将此行导入公共文件夹中的 .htaccess 文件,但没有任何变化,我有 404 错误,
So I do this, import this lines to .htaccess file in public folder, but nothing change, I have 404 error,
例如,我尝试在 indexController 中创建名为edit"的操作,但是如果我转到http://zf2-tutorial.localhost/index/edit/ 我有 404 错误.
I try to create action named "edit" in indexController, for example, but if I go to http://zf2-tutorial.localhost/index/edit/ I have 404 error.
我必须做什么才能让它工作????????????????????????
What I must do to make it work ?????????????????????
推荐答案
如果您有默认的 MAMP 安装,您可以通过单击顶部的 phpinfo 选项卡从 MAMP 起始页转到 phpinfo.在 phpinfo 页面中,您可以找到 mod_rewrite 是否已加载.只需单击 Cmd + f(在 Mac 上)并输入 mod_rewrite.它应该在加载的模块"部分.
If you have default MAMP installation you can go to phpinfo from MAMP start page by clicking phpinfo tab on top. In phpinfo page you can find if mod_rewrite have been loaded. Just click Cmd + f (on Mac) and type mod_rewrite. It should be in "Loaded Modules" section.
现在您应该设置您的 VirtualHost.打开 /Applications/MAMP/conf/apache/httpd.conf
并将其添加到此文件的末尾:
Now you should setup your VirtualHost. Open /Applications/MAMP/conf/apache/httpd.conf
and add this to end of this file:
<VirtualHost *:8888>
ServerName zf2-tutorial.localhost
DocumentRoot /absolute/path/to/your/projects/zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory /absolute/path/to/your/projects/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
现在添加这一行
127.0.0.1 zf2-tutorial.localhost localhost
到您的 /private/etc/hosts
文件.
重启 MAMP.
转到 http://zf2-tutorial.localhost:8888/ 后,您应该看到欢迎使用 Zend Framework 2"起始页.转到 http://zf2-tutorial.localhost:8888/1234 后,您应该看到 404 ZF2 页面 这个页面的内容应该是这样的:
After going to http://zf2-tutorial.localhost:8888/ you should see "Welcome to Zend Framework 2" start page. After going to http://zf2-tutorial.localhost:8888/1234 you should see 404 ZF2 page the content of this page should be something like that:
如果你看到类似的东西,一切都很正常.这意味着您的 mod_rewrite 正在工作,并且您已被重定向到 404 ZF2 页面 插入 default apache未找到"页面 就像那样
If you see something like that everything is perfectly normal. It means that your mod_rewrite is working and you have been redirected to 404 ZF2 page insted of default apache "Not Found" page like that
这篇关于Zend Framework 2 .htaccess mamp pro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!