Search code examples
apache.htaccessmod-rewritehttp-redirectdocument-root

Redirect 2 different domains to 2 different directory + .htaccess


Here is my directory structure:

root
root/cakephp
root/wordpress

How to redirect

  • example.com/cakephp to cakephp directory
  • and redirect the rest of urls to wordpress

We have bespoke website that we want to configure it separately with cakephp and all the rerequest like example.com/cakephp should go to cakephp directory and the rest of requestes goes to our CMS (which is wordpress in wordpress folder).


Solution

  • In the root .htaccess have this rule:

    RewriteEngine On
    
    RewriteRule !^(cackephp|wordpress)/ wordpress%{REQUEST_URI} [L,NC]