CakePHP MAMP mod_重写不起作用?
最近一直在深入研究PHP和Cake框架,并试图在我的MacBook上使用Cake 2.4.7和MAMP建立一个新项目 我想使用DebugKit插件,在安装过程中,它表明我的mod rewrite没有正确配置,因为DebugKit的样式似乎没有加载。我觉得我已经尝试了人们所建议的一切来让它工作,但似乎没有任何效果 这里是我在论坛上找到并尝试过的所有东西的列表,如果有人还有其他我可以尝试的东西,我将非常感激CakePHP MAMP mod_重写不起作用?,php,.htaccess,cakephp,mod-rewrite,mamp,Php,.htaccess,Cakephp,Mod Rewrite,Mamp,最近一直在深入研究PHP和Cake框架,并试图在我的MacBook上使用Cake 2.4.7和MAMP建立一个新项目 我想使用DebugKit插件,在安装过程中,它表明我的mod rewrite没有正确配置,因为DebugKit的样式似乎没有加载。我觉得我已经尝试了人们所建议的一切来让它工作,但似乎没有任何效果 这里是我在论坛上找到并尝试过的所有东西的列表,如果有人还有其他我可以尝试的东西,我将非常感激 git克隆https://github.com/cakephp/debug_kit.git在
git克隆https://github.com/cakephp/debug_kit.git
在app/Plugin
目录中创建debug\u kit
CakePlugin::load('DebugKit')
inapp/Config/bootstrap.php
Configure::write('debug',2)
inapp/Config/core.php
?php echo$this->元素('sql_dump');?>代码>来自app/View/Layouts/default.ctp
.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
app/webroot
目录中选中.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
echo phpinfo()的输出代码>对于存在的mod_rewrite
/Applications/MAMP/conf/apache/httpd.conf
中,将
指令的所有AllowOverride None
更改为AllowOverride all
echo$this->Html->css(数组('cake.generic.css')代码>以防它碍事
找到了!在这一行的某个地方,我认为在
Config/core.php
中取消注释这一行是个好主意:
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
但这是针对未启用url重写的情况,因此将注释放回原处就成功了 不编辑.htaccess文件怎么样?让他们保持cakephp默认设置的状态。只是将他们全部恢复为默认设置,看起来我在修复问题的尝试中添加了一些东西。但恐怕还是不一样,谢谢你的建议!