本文介绍了CakePHP的不工作在Ubuntu URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有。这一次,我尝试CakePHP的,但我有URL重写不正确的服务器上配置1)帮我配置2)我不/不能使用URL重写。我知道这是Apache和htaccess的问题,如在/ etc / apache2的/网站-avaliable /默认和每个目录的.htaccess。

all. This time I try cakephp, but I have got "URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting". I could know this is apache and .htaccess issues such as /etc/apache2/sites-avaliable/default and each directory .htaccess.

我的开发环境...


  • Ubuntu12.04在VMware fusion4

  • apache2.2.22

  • mysql5.5

  • php5.3.10

  • cakephp2.1

我的流程进行后续处理...

My process is followed...

1)/etc/apache2/httpd.conf

1)/etc/apache2/httpd.conf

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

2)使mod_rewrite的

2)enabling mod_rewrite

sudo a2enmod rewrite
sudo service apache2 reload

3)编辑/ etc / apache2的/网站-avaliable /默认(AllOverride无以AllOverride所有)

3)editing /etc/apache2/sites-avaliable/default (AllOverride None to AllOverride All)

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>

prompt: sudo service apache2 reload

4)编辑或检查每个.htaccess文件
- >蛋糕根目录

4)editing or checking each .htaccess file->cake root directory

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
   </IfModule>

- >应用程序根目录

->app root directory

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$    webroot/    [L]
   RewriteRule    (.*) webroot/$1    [L]
   </IfModule>

- > webroot的目录

->webroot directory

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

此问题就解决了​​,谢谢你。

This issue is solved, thank you.

推荐答案

我有这个问题为好。原来在的.htaccess 文件没有得到复制旁边CakePHP的来源。使用cp命令,或者没有在文件浏览器中可见隐藏的文件,除非你复制的顶级目录时,这是一个常见的​​问题。

I had this problem as well. Turns out the .htaccess file was not getting copied alongside the cakePHP source. This is a common issue when using the cp command or not having hidden files visible in a file browser, unless you copy the top-level directory.

在做文件直接拷贝到固定对我来说我的项目文件夹,而不必惹我的Apache设置。

Doing a direct copy of the file to my project folder fixed it for me without having to mess with my apache settings.

cp ~/git/cakePHP/.htaccess ~/project/folder/

这篇关于CakePHP的不工作在Ubuntu URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 13:41