gpt4 book ai didi

php - CakePHP URL 重写在 Ubuntu 上不起作用

转载 作者:行者123 更新时间:2023-12-04 18:34:42 25 4
gpt4 key购买 nike

我似乎无法在带有 apache2 的 Ubuntu 12.04 服务器上进行 URL 重写,并且当默认页面加载(主页)时,它只是没有 CSS 的纯文本。我正在使用 Cake 2.3.9,并且在全新安装到/var/www/时收到以下消息。所以我的根目录看起来像

/var/www/app
/var/www/lib
/var/www/index.php
/var/www/.htaccess
....

我得到的错误是

URL rewriting is not properly configured on your server. 1. Help me configure it 2. I don't / can't use URL rewriting



我尝试了 this post 中的所有内容但我仍然收到消息。

那篇文章中我唯一没有做的是接受的答案,即

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. Doing a direct copy of the file to my project folder fixed it for me without having to mess with my apache settings.



该用户是否建议确保 .htaccess 是/var/www?我不太明白他们的建议。我在本地下载了 Cake,然后使用 SFTP 将其上传到我的 ubuntu 服务器上的/var/www。

除非有一些替代的 modrewrite 设置,否则我几乎肯定它已启用。当我输入 sudo a2enmod rewrite它说 Module rewrite already enabled
我也试过了 here仍然没有运气。我完全被困住了。

最佳答案

是的,.htaccess 需要位于公共(public) Web 根目录中 - 在这种情况下是/var/www。
确保您的 Web 服务器也可以读取该文件。

如果这不起作用:
确保安装并启用了 mod_rewrite 模块。它应该在 Ubuntu 12.04 上。
您可以通过列出/etc/apache2/mods-enabled 的内容来检查。您应该看到 rewrite.load 列出。

如果没有,您可以这样启用它:

sudo -i
cd /etc/apache2/mods-enabled
ln -s ../sites-available/rewrite.load rewrite.load
apache2ctl restart

关于php - CakePHP URL 重写在 Ubuntu 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20306573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com