My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
AlternateFileLayouts  
Getting Minify to work in a subdirectory of the document root
Phase-Deploy
Updated Mar 8, 2012 by mrclay....@gmail.com

If you test sites in a subdirectory (e.g. http://localhost/testSite/) rather than a virtualhost, then you'll need to adjust the way you use Minify to rewrite CSS correctly.

1. Place the following in min/config.php:

// Set the document root to be the path of the "site root"
$min_documentRoot = substr(__FILE__, 0, -15);

// Set $sitePrefix to the path of the site from the webserver's real docroot
list($sitePrefix) = explode('/min/index.php', $_SERVER['SCRIPT_NAME'], 2);

// Prepend $sitePrefix to the rewritten URIs in CSS files
$min_symlinks['//' . ltrim($sitePrefix, '/')] = $min_documentRoot;

2. In the HTML, make your Minify URIs document-relative (e.g. min/f=js/file.js and ../min/f=js/file.js), not root-relative.

Now the min application should operate correctly from a subdirectory and will serve files relative to your "site" root rather than the document root. E.g.

environment production testing
server document root /home/mysite_com/www /var/www
$min_documentRoot ("site root") /home/mysite_com/www /var/www/testSite
$sitePrefix (empty) /testSite
Minify URL http://mysite.com/min/f=js/file1.js http://localhost/testSite/min/f=js/file1.js
file served /home/mysite_com/www/js/file1.js /var/www/testSite/js/file1.js

Caveats:

  • This configuration may break the Builder application (located at /min/builder/) used to create Minify URIs, but you can still create them by hand.
  • Make sure you don't reset $min_symlinks to a different value lower in your config file.

Comment by jasondho...@gmail.com, Mar 16, 2010

To avoid issues like this in the future just make every web application run on its own virtual host, its pretty easy to setup a virtual host in wampserver. T

his wont be the only issue you will run into with your website once it goes live you will have linking issues etc.. To setup a virtual host you can read up on it at this tutorial http://vzio.com/learn_web-design_development/wampserver-learn_web-design_development/custom-virtual-host-on-wampserver/

-jason

Comment by gerits.a...@gmail.com, Nov 24, 2010

This method does not work, I still have the wrong path with an IP address instead of localhost

Comment by project member mrclay....@gmail.com, Nov 24, 2010

@gerits.aurelien ask on the support list. My first guess is that $SERVER['DOCUMENT_ROOT'] points differently based on the host header, so sending an IP could change that.

Comment by pixrepor...@gmail.com, Apr 19, 2011

This method will not works if you have subdirs in your URLs, eg: http://localhost/mysite/category/mycategory/list (until you want to manually change the relative path to minify on all pages...).

Comment by mo.ah...@hmi-tech.net, Dec 20, 2011

my entire sites works such i do not need to change any files to shift from development to production.

thus am hesitant to make two version of the files


Sign in to add a comment
Powered by Google Project Hosting