Static and dynamic rewrites


/ Published in: Apache
Save to your folder(s)



Copy this code and paste it in your HTML
  1. RewriteEngine On
  2. RewriteBase /
  3.  
  4. RewriteRule ^images/.*$ - [L] # serve only static images
  5.  
  6. # redirect dev request from external IPs to production site
  7. RewriteCond %{SERVER_NAME} ^dev.example.com$
  8. RewriteCond %{REMOTE_ADDR} !^127.0.0.1$
  9. RewriteRule (.*) http://www.example.com/$1 [R=302,L]
  10.  
  11. RewriteCond %{REQUEST_URI} !/css/ # do not apply this rule to /css/ folder
  12. RewriteCond %{REQUEST_FILENAME} !-f
  13. RewriteCond %{REQUEST_FILENAME} !-d
  14. RewriteRule ^.*$ /index.php [QSA,L] # not found requests redirect to index.php

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.