mod_rewrite的绝对路径在.htaccess中 - 调高404 [英] mod_rewrite to absolute path in .htaccess - turning up 404

查看:212
本文介绍了mod_rewrite的绝对路径在.htaccess中 - 调高404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要地图的一些目录中的URL:

I want to map a number of directories in a URL:

www.example.com/manual
www.example.com/login

对于Web根目录之外的目录。

to directories outside the web root.

我的Web根目录是

/www/htdocs/customername/site

我要重定向到手册中

the manual I want to redirect to is in

/www/customer/some_other_dir/manual

在mod_alias中,这将是等于

In mod_alias, this would be equal to

Alias /manual /www/customer/some_other_dir/manual

但我只有的.htaccess 访问,我不能使用别名,所以我必须使用的mod_rewrite

but as I have access only to .htaccess, I can't use Alias, so I have to use mod_rewrite.

在<一个什么我有现在href=\"http://stackoverflow.com/questions/2188274/whats-wrong-with-this-mod-rewrite-statement/2188317#2188317\">this问题是以下内容:

RewriteRule ^manual(/(.*))?$ /www/htdocs/customername/manual/$2 [L]

这部作品在这个意义上,请求承认和正确重定向,但我得到一个404,看起来像这样(注意绝对路径):

this works in the sense that requests are recognized and redirected properly, but I get a 404 that looks like this (note the absolute path):

The requested URL /www/htdocs/customername/manual/resourcename.htm 
was not found on this server.

不过,我已经用PHP检查:回声file_exists(...)和文件肯定存在

为什么会变成这样?据mod_rewrite的文档,这是可能的,即使在一个.htaccess文件。据我所知,做在.htaccess mod_rewrite的时候,会有一个自动preFIX,但不是绝对路径,会吗?

why would this be? According to the mod_rewrite docs, this is possible, even in a .htaccess file. I understand that when doing mod_rewrite in .htaccess, there will be an automated prefix, but not to absolute paths, will it?

这不应该是一个权利问题,或者:这是不是在网站根目录,但FTP树只有一个用户,主要的FTP帐户​​,访问内

It shouldn't be a rights problem either: It's not in the web root, but within the FTP tree to which only one user, the main FTP account, has access.

我可以改变在控制面板随时随地的Web根目录,但我想这个工作,我所描述的方式。

I can change the web root in the control panel anytime, but I want this to work the way I described.

这是共同主办,所以我要在错误日志的访问权限。

This is shared hosting, so I have no access to the error logs.

我只是检查,这是不是一个错误301重定向,只是一个内部重写。

I just checked, this is not a wrongful 301 redirection, just an internal rewrite.

推荐答案

据我所知mod_rewrite的工作在'协议'水平(在电线上HTTP的意思)。所以我怀疑你正在HTTP 302中的位置的目录路径。

AFAIK mod_rewrite works at the 'protocol' level (meaning on the wire HTTP). So I suspect you are getting HTTP 302 with your directory path in the location.

所以,我怕你会被卡住,除非..你的主机,您可以遵循符号链接;这样你就可以链接到该位置(假设你有shell访问或这是可能使用FTP或控制面板)当前的文档根目录下。

So I'm afraid you might be stuck unless.. your hosting lets you follow symbolic links; so you can link to that location (assuming you have shell access or this is possible using FTP or your control panel) under your current document root.

编辑:它实际上提到 URL-文件相挂钩的文档所以现在我怀疑目录指令都不允许足够的权限。

It actually mentions URL-file phase hook in the docs so now I suspect the directory directives aren't allowing enough permissions.

这篇关于mod_rewrite的绝对路径在.htaccess中 - 调高404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆