Zend Framework 2 .htaccess mamp pro

前端 未结 2 381
忘掉有多难
忘掉有多难 2021-01-23 09:57

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-appl

相关标签:
2条回答
  • 2021-01-23 10:24

    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.

    0 讨论(0)
  • 2021-01-23 10:51

    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:

    zf2 405

    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

    apache default 404 page

    0 讨论(0)
提交回复
热议问题