Advertisement
Guest User

htaccess rewrite subdirectories based on env variable

a guest
Mar 8th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <IfModule mod_rewrite.c>
  2.  
  3. SetEnv ENVIRONMENT production
  4.  
  5. Options +FollowSymlinks
  6. RewriteEngine On
  7. RewriteBase /
  8.  
  9. RewriteCond %{HTTP_HOST} ^movieapp.ds$
  10. RewriteRule (.*) $1 [E=ENVIRONMENT:development]
  11.  
  12. #Redirects frontend app requests
  13. RewriteCond %{ENV:ENVIRONMENT} ^development$
  14. RewriteRule ^scripts/(.*)$ app/scripts/$1 [L]
  15. RewriteRule ^styles/(.*)$ app/styles/$1 [L]
  16. RewriteRule ^images/(.*)$ app/images/$1 [L]
  17. RewriteRule ^views/(.*)$ app/views/$1 [L]
  18.  
  19.  
  20. RewriteCond %{ENV:ENVIRONMENT} ^production$
  21. RewriteRule ^scripts/(.*)$ dist/scripts/$1 [L]
  22. RewriteRule ^styles/(.*)$ dist/styles/$1 [L]
  23. RewriteRule ^images/(.*)$ dist/images/$1 [L]
  24. RewriteRule ^views/(.*)$ dist/views/$1 [L]
  25.  
  26.  
  27.  
  28. #Removes access to the system folder by users.
  29. #Additionally this will allow you to create a System.php controller,
  30. #previously this would not have been possible.
  31. #'system' can be replaced if you have renamed your system folder.
  32. RewriteCond %{REQUEST_URI} ^system.*
  33. RewriteRule ^(.*)$ index.php?/$1 [L]
  34.  
  35. #When your application folder isn't in the system folder
  36. #This snippet prevents user access to the application folder
  37. #Submitted by: Fabdrol
  38. #Rename 'application' to your applications folder name.
  39. RewriteCond %{REQUEST_URI} ^application.*
  40. RewriteRule ^(.*)$ index.php?/$1 [L]
  41.  
  42. #Checks to see if the user is attempting to access a valid file,
  43. #such as an image or css document, if this isn't true it sends the
  44. #request to index.php
  45. RewriteCond %{REQUEST_FILENAME} !-f
  46. RewriteCond %{REQUEST_FILENAME} !-d
  47. RewriteRule ^(.*)$ index.php?/$1 [L]
  48.  
  49. </IfModule>
  50.  
  51. <IfModule !mod_rewrite.c>
  52. # If we don't have mod_rewrite installed, all 404's
  53. # can be sent to index.php, and everything works as normal.
  54. # Submitted by: ElliotHaughin
  55.  
  56. ErrorDocument 404 index.php
  57. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement