How to make a sub folder site appear as the root website

  Previous article Next article  

How to make a sub folder site appear as the root website

  Article optimized for CMSMS 2.x

  Author:
  Last updated: 18-07-2017
  Comments: 0

To have a more organized root folder at my web server I have my personal website installed in a sub folder. Now I have a better overview over all sub websites.

So the CMS Made Simple™ website is installed in the folder http://www.website.com/www.
But for the primary domain it isn't that nice to have the second www in the pretty URL's. With a .htaccess file you can hide the sub domain name in the URL's. Note this only works on an Apache web server, you sadly can't use a .htaccess file on a Windows server...

  How to use

Server root folder

In the root web server folder I made a .htaccess file containing:

#
RewriteEngine On
RewriteBase /www

# redirect to www-directory and hide the /www in the URL
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^www(/?|/.+)$ /www%{REQUEST_URI} [L]

Note: My sub folder is named www. Has your sub folder an other name, change the text www above into your sub folders name!

Server sub folder

The config.php settings of the website are just like a 'regular' CMSMS™ website:

$config['root_url'] = 'http://www.website.com';
$config['url_rewriting'] = 'mod_rewrite';

In the sub folder I use the default Core .htaccess file. There is NO need to change the RewriteBase

# If your CMSMS installation is in a subdirectory of your domain, you may need to specify the relative path (from the root of the domain) here.
# i.e: RewriteBase /cmsms
RewriteBase /

The described method works for my server setup. It might be that on other servers it doesn't work and you need to change it.
Please post your remarks below and I will update the article to make it more complete!


A2 Webhosting CMS Made Simple


A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  0 Comments

No comments yet...

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

How to make a sub folder site appear as the root website

  Article optimized for CMSMS 2.x

  Author:
  Last updated: 18-07-2017
  Comments: 0

A2 Webhosting CMS Made Simple