Zend Framework 2 .htaccess mamp pro

自作多情 提交于 2019-12-02 04:40:07

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!