开发者

Absolute file paths in mod_rewrite - allowed?

This is a follow-up to this question.

I am trying to build a mod_rewrite rule where 开发者_开发技巧the rewriting target is an absolute path outside the web root, like

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

I need to do this because I can't use Alias in a .htaccess context (shared hosting).

There are responses hinting at this not being possible at all.

Is this true? I can't find any clear info in the manual.

Could somebody clarify when absolute paths are possible, and when they are not?


It is certainly possible to use absolute file paths in your server config.

You won't be able to do that in a .htaccess file though, since that would give you access to read files outside your document root, even files from other customers that were supposed to be protected by a <Location ...> block.


The replacement in a RewriteRule is a URL path. An absolute path in the replacement is an absolute URL path, not an absolute file path. If you can't reference a resource (i.e. it doesn't have a URL), then the rewrite engine can't help you.

Instead, try creating a symlink, though you'll need the FollowSymLinks or SymLinksIfOwnerMatch option enabled. If you don't have shell access, you can write a script to create symlinks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜