-1

We are multi locale site and all are using same js and css.

So How can I redirect all JS,CSS files to same folder.

My URL are like

server.com/uk/_ui/folder/1.js  
server.com/uk/_ui/folder2/1.js
server.com/fr/_ui/folder/1.js  
server.com/fr/_ui/folder2/1.js  

how can I write redirection rule so that if the url contains _ui check the docroot excludeing country tag(fr,uk)

My VirtualHost are

<VirtualHost *:80>  
ServerName server1.com  
AliasMatch ^/[a-z]+/_ui/(.*)$ /var/www/html/$1  
JkMount /jkstatus status  
JkMount /* loadbalancer  
JkUnMount /*/_ui/* loadbalancer  
</VirtualHost>  

Thanks in advance

Sreenivas A.

sree
  • 868
  • 2
  • 12
  • 35
  • The way you are doing JkMount with mod_jk may well be affecting the way AliasMatch works. Try adding JkUnmMount /_ui/* loadbalancer and/or disabling mod_jk entirely to see how it affects things. – Ketola Dec 05 '12 at 15:30

1 Answers1

1

AliasMatch does exactly what you are looking for. It maps directories based on regular expressions to different folders on filesystem.

AliasMatch ^/[a-z]+/_ui/(.*)$ /full/path/to/your/docroot/$1

This is much better than doing a redirect, since it involves only a single request from the server.

Ketola
  • 2,767
  • 18
  • 21
  • Thanks your quick response.When I try with above seems like they are not picking the file showing 404 errors.I added this AliasMatch ^/([a-z]+)/_ui/(.*)$ /var/www/html/$1 . How Can i debug this? – sree Dec 05 '12 at 13:11
  • The first pattern match was not needed, so I removed it altogether. The regexp is now fixed and should work as expected. – Ketola Dec 05 '12 at 13:33
  • Please use the fixed AliasMatch in the answer. – Ketola Dec 05 '12 at 13:44
  • I tried
     AliasMatch ^/[a-z]+/_ui/(.*)$ /var/www/html/$1 .And i tried the url http://hostname/uk/_ui/common/js/reorder.min.js .Url is into infinite loop and appending index.html everytime into it.
    – sree Dec 05 '12 at 13:49
  • in logs [Wed Dec 05 20:28:05 2012] [error] [client 10.255.255.52] File does not exist: /var/www/html/uk which means that it's looking from /var/www/html/uk/_ui where it should be searh from /var/www/html/_ui – sree Dec 05 '12 at 13:59
  • You are still using the old, uncorrected AliasMatch then. Replace the one you are using now with the updated one from my answer above. The correct AliasMatch is: AliasMatch ^/[a-z]+/_ui/(.*)$ /full/path/to/your/docroot/$1 – Ketola Dec 05 '12 at 14:51
  • Sorry to bothering you agin..I am using the same Aliasmatch. AliasMatch ^/[a-z]+/_ui/(.*)$ /var/www/html/$1 . But still saying that page not found and the error is not able to find uk folder.Thanks for you patience – sree Dec 05 '12 at 15:03
  • Could you please update your question with your current configuration for your virtual host. I tested the setting on my servers and it works as expected. Make sure that you have restarted Apache and that it is using the correct config file. With the AliasMatch above it should definitely not be looking for /var/www/html/uk - that was the error in my initial answer. – Ketola Dec 05 '12 at 15:16