Welcome Guest, Not a member yet? Register   Sign In
Useful .htaccess file for images/css/js rerouting.
#1

[eluser]MPress[/eluser]
Just in case this might be useful for someone else:

I modified the recommended .htaccess file from the user guide to the following:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|system|images|css|js)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^(images|css|js)/(.*) /system/application/views/$1/$2 [L]

now all requests to

{domain}/images/
{domain}/css/
{domain}/js/

are routed internally to

{domain}/system/application/views/images/
{domain}/system/application/views/css/
{domain}/system/application/views/js/

respectively.

I was originally thinking it would be better to route js requests to a subdir of controllers but took the views "route" if only for consistency.

This needs additional filtering because currently you cannot access a controller named 'system' without first prefixing it with index.php/. I don't know jack about regular expressions so any help in this regard would be much appreciated.
#2

[eluser]alin4lex[/eluser]
hello,

how sould i do to route:

./themes/theme1/css
./themes/theme1/images
./themes/theme1/scripts

to:

system/application/views/theme1/css
system/application/views/theme1/images
system/application/views/theme1/scripts


thanks!
#3

[eluser]MPress[/eluser]
[quote author="alin4lex" date="1191157400"]hello,

how sould i do to route:

./themes/theme1/css
./themes/theme1/images
./themes/theme1/scripts

to:

system/application/views/theme1/css
system/application/views/theme1/images
system/application/views/theme1/scripts


thanks![/quote]

This should work:
Code:
RewriteRule ^themes/theme1/(css|images|scripts)/(.*) /system/application/views/theme1/$1/$2 [L]

Or, for multiple theme rerouting, you can do the following:
Code:
RewriteRule ^themes/(theme1|theme2)/(css|images|scripts)/(.*) /system/application/views/$1/$2/$3 [L]
#4

[eluser]alin4lex[/eluser]
thanks,

but i did it this way : http://ellislab.com/forums/viewthread/61856/




Theme © iAndrew 2016 - Forum software by © MyBB