[英]CakePHP 2.4.3 URL-Rewriting module not working
Ok... 好...
Getting tired of this issue. 厌倦了这个问题。 So I thought I would ask here
所以我想在这里问
Just to clarify I did follow the Cake PHP documentation on this. 为了澄清起见,我确实遵循了Cake PHP文档。 I did google this for almost 2 hours and guess what ... no luck
我用谷歌搜索了将近2个小时,然后猜猜是什么...
I edited my htaccess file in webroot etc to include: 我在webroot等中编辑了htaccess文件,其中包括:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule>
As recommended by another poster on this site 如本网站另一位海报所推荐
No Luck. 没运气。 Am I missing something special here like a tad of mystical unicorn dust on my installation or am I being stupid?
我是否在这里遗漏了一些特别的东西,例如在我的装置上散发着神秘的独角兽般的灰尘?
Lemme know if you need something else 我知道你是否还需要其他东西
Oh I did a LAMP installation thing a while ago 哦,我前段时间做了LAMP安装
Your guidance will be much appreciated :) 您的指导将不胜感激:)
[edit] cahnged tags to 2.4 instead of 2.3 <-- My bad [编辑]标记从2.4改为2.3,而不是<-我的坏
If you had to enable mod_rewrite then chances are, your default apache setup will also need to be changed to allow the .htaccess to execute correctly. 如果必须启用mod_rewrite,那么还需要更改默认的Apache设置,以允许.htaccess正确执行。 By default, most .htaccess rules in publicly accessible directories will be denied.
默认情况下,公共可访问目录中的大多数.htaccess规则将被拒绝。
Depending on your setup you should have something like this ... 根据您的设置,您应该有这样的东西...
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
deny from all
</Directory>
Found in your config directory for a apache, which may be something like 在您的apache的配置目录中找到,可能类似于
/etc/apache2/sites-available/default
Note that the path above and also the /var/www/ path in your Directory tag above, may be different. 请注意,上面的路径以及上面的Directory标记中的/ var / www /路径可能有所不同。
You will need to change a few things, such as AllowOveride and also a few others to match below. 您将需要更改一些内容,例如AllowOveride以及下面要匹配的其他一些内容。 Inspect for the differences.
检查差异。
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Once you have changed that, restart apache and hopefully you will see that the rules in your .htaccess file are now executing. 更改后,重新启动apache,希望您会看到.htaccess文件中的规则正在执行。
I think you're missing the /$1 part. 我认为您缺少/ $ 1部分。
My .htaccess in webroot looks like this: 我在webroot中的.htaccess如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
I have also had issues in the past with rewrite and cakePHP on some servers, I needed to add a slash at the start of the filename, as shown: 过去在某些服务器上我也遇到了rewrite和cakePHP的问题,我需要在文件名的开头添加一个斜杠,如下所示:
RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]
however I don't think that this is your issue here. 但是我不认为这是您的问题。
/var/www/app/webroot/.htaccess /var/www/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
/var/www/app/.htaccess /var/www/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/var/www/.htaccess /var/www/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Please use these .htaccess files to configure you app 请使用这些.htaccess文件配置您的应用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.