Search code examples
php.htaccessforwarding

forwarding all traffic to folder


I am currently using the following to forward all incoming traffic to the cms folder in root.

<?php header("location:/cms"); ?>

Is there anyway to keep the url as the sites root. i.e. mydomain.com not mydomain.com/cms

any pointers appreciated,


Solution

  • You can achieve it using mod_rewrite. I think this works (put this inside .htaccess under document root):

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/cms/
    RewriteRule ^(.*)$ /cms/$1
    

    Also you can just change document root DocumentRoot "/home/www/mysite" to DocumentRoot "/home/www/mysite/cms"