Chin
Chin

Reputation: 12712

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,

Upvotes: 0

Views: 90

Answers (2)

Sadrul
Sadrul

Reputation: 11

I think mode_rewrite is one of the best solution for this. You can put the following code into your .htaccess file under root directory:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?yourprimarydomain.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L] 

Upvotes: 1

galymzhan
galymzhan

Reputation: 5523

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"

Upvotes: 1

Related Questions