简体   繁体   中英

How does mod_rewrite work with phar?

I made a phar archive out of my web application source directory. The directory contains 'css' and 'js' directories as well. The static files are addressed as /css/xyz.css etc. in html. When I try to access the application the html is loading fine but the static files are not. I tried adding apache rewrite rule which maps /css/xyz.css to /app.phar/css/xyz.css but that doesn't work. Everytime I hit

http://hostname/css/xyz.css

it is loading index.php.

Do I have to modify all static file references to /app.phar/css/xyz.css ? Static file urls relative to phar file are working fine.

Also, is mod_rewrite completely unusable when using phar?

Thanks!

mod_rewrite is an Apache module. As soon as Apache runs the .phar file via PHP, it's all in PHP's hands. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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