Page 1 of 1
[SOLVED] make sub folder cmsms site appear as root site
Posted: Sat Nov 01, 2014 7:23 pm
by blackhawk
Within my live web host environment, if I install my cmsms directory in a sub folder like,
...are there are configuration tactics within cmsms to reveal this site as...
for all links and and pages within this sub directory?
Thanks for any tips
Re: How to make sub folder cmsms site appear as root site
Posted: Sat Nov 01, 2014 8:33 pm
by Rolf
I have main website in a subfolder named www
.htaccess in the root of the server
Code: Select all
#
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]
Re: How to make sub folder cmsms site appear as root site
Posted: Sat Nov 01, 2014 8:56 pm
by blackhawk
Thank you Rolf,
appreciate your help always!
Let me go ahead and try this step...
Re: How to make sub folder cmsms site appear as root site
Posted: Sat Nov 01, 2014 9:29 pm
by JohnnyB
Maybe rewrite the url without that sub directory.
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)cmsms2015
RewriteRule ^(.*)$ cmsms2015/$1 [QSA]
The above might work. But, if you are using SEO mod rewrite style URLS, then it might get a bit tricky.... I didn't test this so, you'll need to experiment.
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)cmsms2015
RewriteRule ^(.*)$ cmsms2015/index.php?page=$1 [QSA,L]
And, what if the admin directory is inside of that cmsms2015/ directory? We probably shouldn't remove it from the URL then....
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)cmsms2015
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ cmsms2015/index.php?page=$1 [QSA,L]
if the line
RewriteCond %{REQUEST_URI} !(.*)cmsms2015
doesn't seem to help, you can try
RewriteCond %{REQUEST_URI} !^/cmsms2015
If you do any 'www' redirects to add or remove the www prefix from the domain, you'll need to put that first, above all the other stuff above.
Re: How to make sub folder cmsms site appear as root site
Posted: Sun Nov 02, 2014 6:26 am
by Jeff
The proper way (if your host allows it) is it update the site profile/definition to the new root directory.
Jeff
Re: How to make sub folder cmsms site appear as root site
Posted: Sun Nov 02, 2014 12:01 pm
by psy
right or wrong, this is how i do it.
1. .htaccess in root directory where my sub dir is 'cms', eg:
Code: Select all
RewriteEngine On
# force www IN URL
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
# END force www IN URL
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^cms(/?|/.+)$ /cms%{REQUEST_URI} [L]
2. .htaccess in my 'cms' dir is the default supplied by CMSMS.
3. I add the following to my config.php file:
Code: Select all
$config['root_url'] = 'http://www.mysite.com';
$config['root_path'] = '/home/mysite/public_html/cms';
HTH
psy
Re: How to make sub folder cmsms site appear as root site
Posted: Wed Nov 05, 2014 2:47 pm
by blackhawk
Thank you team,
I will play with the following solutions today and see if I can make something work on my end...
Thank you for the rich feedback!

Re: How to make sub folder cmsms site appear as root site
Posted: Tue Nov 18, 2014 6:02 am
by Dr.CSS
Why wouldn't you just move it to the root of the site instead of having in a sufolder..?
Re: How to make sub folder cmsms site appear as root site
Posted: Tue Nov 18, 2014 6:26 am
by psy
Root folders can get very messy. This keeps it tidy.
I use it most often when rebuilding a site for a client. Live site can continue until the new site is ready to launch. Then, forget all the hassle of exporting/importing databases, files, etc - just a minor change to the config.php file and update the htaccess files to point to the new site subfolder as the TLD and it's job done.
Re: How to make sub folder cmsms site appear as root site
Posted: Tue Nov 18, 2014 11:24 am
by paulbaker
psy wrote:Then, forget all the hassle of exporting/importing databases
You wouldn't need to do anything to the database if you are just moving the website up one directory level. Personally I move the files, doesn't take long and when I look at the site months/years later (when I have forgotten all about it) it's obvious what is going on without having to dig in to htaccess files etc.
But I guess much of this thread simply boils down to personal preference....as long as it works, who cares about the technicalities?

[SOLVED] How to make sub folder cmsms site appear as root si
Posted: Tue Dec 02, 2014 3:02 am
by blackhawk
I like the archiving approach for sub folders, this way I can go back and see what I did on older sites. I solved my problem by un-assigning my add-on domain name, and then re-assigning it again to the newer sub folder, all through my cPanel. I can now do this every single time there is a major web site upgrade, which may also represent a newer cmsms environment too.
Thanks!