Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 重写相对路径的规则?_Apache_Mod Rewrite - Fatal编程技术网

Apache 重写相对路径的规则?

Apache 重写相对路径的规则?,apache,mod-rewrite,Apache,Mod Rewrite,我在浏览器中得到的错误是: The requested URL /home/user/public_html/some_folder was not found on this server. apache日志是: [Sat Aug 17 20:57:57 2013] [error] [client ] File does not exist: /var/www/html/home 因此,我自然会想,我会尝试RewriteBase/../../../../home/user/public\u

我在浏览器中得到的错误是:

The requested URL /home/user/public_html/some_folder was not found on this server.
apache日志是:

[Sat Aug 17 20:57:57 2013] [error] [client ] File does not exist: /var/www/html/home
因此,我自然会想,我会尝试
RewriteBase/../../../../home/user/public\u html/
,但这给了我:

[Sat Aug 17 20:59:22 2013] [error] [client ] Invalid URI in request GET /~user/ HTTP/1.1
我该怎么做

.htaccess很简单:

RewriteEngine On

RewriteBase /../../../home/user/public_html/

RewriteRule  index.php                 some_folder/index.html  [L]

您可以使用符号链接

cd /var
cp /var/www /var/backup_www
rm -rf /var/www
ln -s /home/user/public_html/ www
并在httpd.conf中启用以下符号链接

<Directory /var/www>
    Options FollowSymLinks
</Directory>

<Directory /home/user/public_html>
    Options -FollowSymLinks
</Directory>

选项如下符号链接
选项-FollowSymLinks


或者,只需更改服务器/vhost的DocumentRoot。

能否详细说明每个步骤的具体用途?我没有根访问权限。那么这应该由您的主机配置。任何像样的共享主机服务都会提供支持。事实上,我没有使用共享主机。这是我朋友设置的centos web服务器,他也不太明白问题所在。我希望有关stackoverflow的问题能为我们双方澄清。您需要root访问权限才能正确配置服务器。这是没有办法的。有时候有人为你做。。。但他们是通过根访问来实现的,这不是vhost-AFAIK。上面写着
。由于selinux,符号链接无法工作。听起来您的重写规则可能与此类似:
RewriteRule^(+$/some/value/here
——如果是这样,则单词
some
前面的
/
告诉apache
/some/value/here
是一个绝对url。相反,请尝试将
/home/user/public_html
预先添加到规则中,使其看起来像这样:
重写规则^(+$/home/user/public_html/some/value/here
,然后让我(我们)知道发生了什么。相同的错误。文件不存在。如果只使用
RewriteBase/
,会发生什么?哎呀。我输入了/home/user而不是我的实际用户名。。。我得到的错误是
文件不存在:/var/www/html/some_folder
。。。