Tuesday, July 24, 2012

Using mod_rewrite to redirect web pages

There are plenty of tutorials to get this done but in its simpliest form redirecting an entire page to a different url all all together allows for greater internal security.  This can be done by using htaccess file to create a re-write rule.  A good example of code would look like this:


   RewriteEngine on

   RewriteCond %{HTTP_HOST} ^x\.x\.x\.x$
   RewriteRule ^(.*)$ https://x.x.x.x/myapp/$1 [L,R=301]

   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]


Where "x" is the IP address separated by the dotted "." notation


No comments:

Post a Comment