问题
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
To test that your .htaccess file is working, navigate to http://zf2-tutorial.localhost/1234 and you should see this:
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]
So I do this, import this lines to .htaccess file in public folder, but nothing change, I have 404 error,
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 ?????????????????????
回答1:
Validate that your httpd.conf has the rewrite module enabled. Usually in /etc/apache2, make sure you have the line LoadModule rewrite_module libexec/apache2/mod_rewrite.so
in the module section.
回答2:
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.
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>
Now add this line
127.0.0.1 zf2-tutorial.localhost localhost
to your /private/etc/hosts
file.
Restart MAMP.
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:
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
来源:https://stackoverflow.com/questions/13827304/zend-framework-2-htaccess-mamp-pro