相当于 Apache 重写语法中的 PHP 目录名(__FILE__)?
图像是从 Apache 公共文件夹之外的文件夹提供的,不需要别名。
关键字是什么(如果存在)来获取包含重写规则的 htaccess 的真实路径?
# /website1.com/public/prod/ --> index.php & .htaccess
# /website1.com/assets/images/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images/(.*)$ REALPATH/../../assets/images/$1 [L]
# REALPATH doesn't work of course
# not wanted :
# RewriteRule ^images/(.*)$ /website1.com/public/prod/assets/images/$1 [L]
Images are served from a folder outside Apache's public folder and Aliases are not wanted.
What is the keyword, if existing, to get the real path of the htaccess that contains the rewriting rules ?
# /website1.com/public/prod/ --> index.php & .htaccess
# /website1.com/assets/images/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images/(.*)$ REALPATH/../../assets/images/$1 [L]
# REALPATH doesn't work of course
# not wanted :
# RewriteRule ^images/(.*)$ /website1.com/public/prod/assets/images/$1 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使使用绝对路径,您也无法访问 .htaccess 目录之外的文件。解决方案可能是在当前文件夹中创建指向图像目录的符号链接,然后将 .htaccess 规则指向该文件。
那么你的规则应该是这样的:
You can't access files outside of .htaccess directory, even using absolute path. Solution could be to make symbolic link in current folder that points to your images directory and then point your .htaccess rule to this file.
Your rule then should look like this: