我已经在 ubuntu 服务器上上传了一个完整的 cakephp 项目,这里我使用了 apache2。
我的项目在我的 locak 服务器(xampp)中正常工作,但在服务器中显示此错误:
The requested URL /users/login was not found on this server.
我的项目位于
var/www/html
.这是我的
.htdocs
文件:<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
我需要一个适当的解决方案。
最佳答案
检查 apache 配置文件是否有 rewrite_module 行并且它没有被注释:
/etc/apache2/apache2.conf
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
还要确保您的覆盖和符号链接(symbolic link)选项在上述 apache 配置中是正确的:
<Directory />
Options FollowSymLinks
AllowOverride All
# Order deny,allow
# Deny from all
</Directory>
根据您的 cakephp 版本,.htaccess 应该像这些。
应用程序/.htacces 蛋糕PHP 2:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/.htacces 蛋糕PHP 3:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
webroot/.htaccess 两个版本:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
关于ubuntu - 在 ubuntu 的 cakephp 项目中,在此服务器上找不到请求的 URL/users/login,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43398851/