Reputation: 53
this is my current .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_URI} .*jpg$|.*gif$|.*png$|.*css$|.*js$ [NC]
RewriteRule (^.*) http://d14t2ycfqndlt4.cloudfront.net/$1 [R=301,
the last 2 lines dont work, althouh when i remove the first cond above, id does work...
what is the problem? thanks!
Upvotes: 2
Views: 851
Reputation: 15778
Something like this should work:
RewriteEngine On
RewriteCond %{REQUEST_URI} (.*)\.(jpg|gif|png|css|js)$ [NC]
RewriteRule (.*) http://d14t2ycfqndlt4.cloudfront.net/$1 [R=301,...]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule (.*) - [NC,L]
RewriteRule (.*) index.php [NC,L]
Note the regular expressions are a bit easier to understand.
Upvotes: 2
Reputation: 784908
This is your corrected and cleaned up .htaccess
code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule \.(?:jpg|gif|png|css|js)$ http://d14t2ycfqndlt4.cloudfront.net%{REQUEST_URI} [R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
Upvotes: 0