Reputation: 47
I am using mod_rewrite in .htaccess. I can't figure out how to get the following done.
/minify/?f=/styles.css
/minify/?f=/js.js
.txt
, .gif
, .jpg
, .png
files should open as they are/page
, /dir/page
, /dir1/dir2/page
) should go to /page.php
/admin/login.php
)Edit:
This is the code that I came up with. It's not elegant, and it fails sometimes. For eg: I can't get /admin/login.php
to work. When I open that URL, it's going to page.php
.
RewriteEngine on
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.txt)$
RewriteRule .* page.php
RewriteRule ^.*?\.css$ /min/?f=/styles.css [L]
RewriteRule ^.*?\.js$ /min/?f=/js.js [L]
Upvotes: 2
Views: 158
Reputation: 80639
Try the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(css|js|png|txt|gif|jpe?g)$
RewriteRule ^ /page.php [L]
RewriteRule \.css$ /minify/?f=/styles.css [NE,L]
RewriteRule \.(js)$ /minify/?f=/$1.$1 [NE,L]
Upvotes: 1