using php5, apache2.2
I'm trying to combine my css and javasc开发者_运维知识库ript files into one file as per this tutorial: http://rakaz.nl/2006/12/make-your-pages-load-faster-by-combining-and-compressing-javascript-and-css-files.html
I don't think the .htaccess rewrite is working right. Here's my .htaccess file:
<IfModule mod_rewrite.c>
RewriteRule ^css/(.*\.css) combine.php?type=css&files=$1
RewriteRule ^javascript/(.*\.js) combine.php?type=javascript&files=$1
</IfModule>
I've tried exactly what was put in the tutorial for the .htaccess, but got a "forbidden" error, so the above is the only thing I got to work and at least not throw an error.
The webpage loads all the content, but just doesn't load the .css, or javascript. I put some debugging inside the "combine.php" page to see if that page even gets called and I get nothing. So I'm thinking that the rewriterule is wrong...but I don't know how to fix it.
Here's how I include it into the html:
<link rel="stylesheet" type="text/css" href="http://somewhere.com/css/layout_2col.css,general.css" />
There are more than 100 posts of people saying it worked...i'm just not one of them.
Can anyone help? Thanks.
@Ronedog: Try without IfModule
--
RewriteEngine On
RewriteBase /
RewriteRule ^css/(.*\.css) /combine.php?type=css&files=$1
RewriteRule ^javascript/(.*\.js) /combine.php?type=javascript&files=$1
The Tag <IfModule mod_rewrite.c>
only works in the apache-configuration.
In your .htaccess file you have to start with
RewriteEngine On
RewriteBase /
followed by your conditions.
The hole block:
RewriteEngine On
RewriteBase /
RewriteRule ^css/(.*\.css) combine.php?type=css&files=$1
RewriteRule ^javascript/(.*\.js) combine.php?type=javascript&files=$1
I found the solution to the problem at this link: http://www.issociate.de/board/post/294029/RewriteEngine_causes_403_Forbidden_error.html
The freeBSD directory inside the httpd.conf needed to have: "Options +FollowSymLinks"...once i added this the forbidden error went away and all worked like it was suppossed to.
Thanks to everyone who helped me troubleshoot.
精彩评论