更新时间:2023-09-11 11:51:10
如果您有默认的 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