Reputation: 449673
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?
Upvotes: 3
Views: 2050
Reputation: 77420
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.
Upvotes: 0
Reputation: 38309
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.
Upvotes: 5