简体   繁体   English

mod_rewrite如何与phar一起使用?

[英]How does mod_rewrite work with phar?

I made a phar archive out of my web application source directory. 我从Web应用程序源目录中制作了一个phar存档。 The directory contains 'css' and 'js' directories as well. 该目录还包含“ css”和“ js”目录。 The static files are addressed as /css/xyz.css etc. in html. 静态文件在html中以/css/xyz.css等地址寻址。 When I try to access the application the html is loading fine but the static files are not. 当我尝试访问应用程序时,html可以很好地加载,但静态文件却不能。 I tried adding apache rewrite rule which maps /css/xyz.css to /app.phar/css/xyz.css but that doesn't work. 我尝试添加将/css/xyz.css映射到/app.phar/css/xyz.css的Apache重写规则,但这不起作用。 Everytime I hit 每当我打

http://hostname/css/xyz.css

it is loading index.php. 它正在加载index.php。

Do I have to modify all static file references to /app.phar/css/xyz.css ? 我是否必须修改对/app.phar/css/xyz.css的所有静态文件引用? Static file urls relative to phar file are working fine. 相对于phar文件的静态文件url工作正常。

Also, is mod_rewrite completely unusable when using phar? 另外,使用phar时mod_rewrite完全不可用吗?

Thanks! 谢谢!

mod_rewrite is an Apache module. mod_rewrite是一个Apache模块。 As soon as Apache runs the .phar file via PHP, it's all in PHP's hands. Apache通过PHP运行.phar文件后,一切就在PHP手中。 You are responsible for sending out the files properly. 您有责任正确地发送文件。

Phar::webPhar() has a $rewrites parameter that lets you simulate mod_rewrite on your own from within the .phar . Phar :: webPhar()具有$rewrites rewrites参数,可让您从.phar内部自己模拟mod_rewrite。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM