为共享主机设置修复 cakephp .htaccess/mod_rewrite

时间:2023-01-19
本文介绍了为共享主机设置修复 cakephp .htaccess/mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试在共享主机设置上安装 cakePHP.将文件解压缩到 ~/public_html/dev/cake 之类的位置并访问相应的 URL(在本例中为 http://hostname/~username/dev/cake/),我收到 404 错误:<小时>未找到

I'm trying to install cakePHP on a shared hosting setup. After extracting the files to a location like ~/public_html/dev/cake and visiting the appropriate URL (in this case http://hostname/~username/dev/cake/), I receive a 404 error:


Not Found

在此服务器上找不到请求的 URL/usr/home/username/public_html/dev/cake/app/webroot/.

The requested URL /usr/home/username/public_html/dev/cake/app/webroot/ was not found on this server.

我怀疑这是因为经过仔细检查,~/public_html的绝对路径实际上不是/usr/home/username/public_html,而是/usr/www/users/username/.

I suspect that the reason for this is that upon closer inspection, the absolute path to ~/public_html is not in fact /usr/home/username/public_html, but rather /usr/www/users/username/.

这是我一直在尝试的(但显然它不起作用):(~/public_html/dev/cake/app/webroot/.htaccess)

Here's what I've been trying (but obviously it's not working): (~/public_html/dev/cake/app/webroot/.htaccess)

<IfModule mod_rewrite.c>  
    RewriteEngine On  
    RewriteBase /usr/www/users/username/dev/cake/app/webroot/ 
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]  
</IfModule>  

不幸的是,这似乎没有任何改变(404 消息保持不变).想法?

Unfortunately, this doesn't seem to change anything (the 404 message remains that same). Thoughts?

推荐答案

不应该

RewriteBase /usr/www/users/username/dev/cake/app/webroot/ 

成为

RewriteBase /~username/dev/cake/

RewriteBase 关心将真实网址映射到虚拟网址,我认为这就是您想要的.

RewriteBase cares about mapping real urls to virtual ones, and I think that's what you want.

这篇关于为共享主机设置修复 cakephp .htaccess/mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:带有 .htaccess 的 PHP 根目录 下一篇:清理放置在 URL 中的字符串的最佳方法是什么,例如 SO 上的问题名称?

相关文章

最新文章