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

fixing cakephp .htaccess/mod_rewrite for shared hosting setups(为共享主机设置修复 cakephp .htaccess/mod_rewrite)
本文介绍了为共享主机设置修复 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Codeigniter htaccess to remove index.php and www(Codeigniter htaccess 删除 index.php 和 www)
htaccess mod_rewrite part of url to GET variable(htaccess mod_rewrite url 的一部分到 GET 变量)
Replacing a querystring parameter value using mod_rewrite(使用 mod_rewrite 替换查询字符串参数值)
.htaccess in subdirectory #39;overriding#39; parent htaccess(子目录“覆盖父 htaccess 中的 .htaccess)
How to rewrite SEO friendly url#39;s like stackoverflow(如何像stackoverflow一样重写SEO友好的url)
Is it okay to have a very long .htaccess file?(有一个很长的 .htaccess 文件可以吗?)