Remove /cms folder from the url

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Remove /cms folder from the url

Post by swarfega »

My cmsms is installed in the folder /cms which currently shows on the website's url.

Id like to remove /cms folder from the url without having to relocate the entire cms to root and have all the current links reflect this.

So from website.com/cms to website.com.

Im using cmsms 1.10.3 with pretty urls.
Last edited by swarfega on Sun Mar 11, 2012 9:40 pm, edited 2 times in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Remove /cms folder from the url

Post by Rolf »

.htaccess in server root

Code: Select all

RewriteEngine On
RewriteOptions inherit
RewriteBase /cms

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^cms(/?|/.+)$ /cms%{REQUEST_URI} [L]
index.html in server root

Code: Select all

<__html>
<head>
<meta http-equiv="refresh" content="0;URL=http://www.cmsmadesimple.org/cms" />
</head>
</__body>
<__body>
</__html>
Website root in subfolder /cms/config.php

Code: Select all

$config['root_url'] = 'http://www.cmsmadesimple.org';
Grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

Thanks very much, appears to be working nicely :D
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url [solved]

Post by swarfega »

oops, spoke too soon. The article list on the right (http://thriplow.org.uk/news.thriplow) is not working.

I suspect I need to do something in htaccess.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Remove /cms folder from the url

Post by Rolf »

Code must be good, at least it works at my website... ;)
Perhaps double check config.php settings
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

Here is my ht and config.php files:

Code: Select all

ErrorDocument 404 /cms/index.php?page=error404
RemoveHandler .php
AddType application/php5-fcgi php
Action application/php5-fcgi /cgi-bin/php5fcgi.fcgi

<IfModule php5_module>
  php_value include_path /ZendGdata
</IfModule>

# ------------------------
# BEGIN Optional settings

Options -Indexes
Options +FollowSymLinks
DirectoryIndex /cms/index.php
RewriteBase /cms
RewriteEngine on
RewriteOptions inherit
#SecFilterEngine Off

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^cms(/?|/.+)$ /cms%{REQUEST_URI} [L]

#Adds .thriplow to categories
RewriteCond %{HTTP_HOST} ^thriplow.org.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.thriplow.org.uk$
#RewriteRule ^news/category/([0-9]+)/(.+)  index.php?mact=News,cntnt01,default,0&cntnt01detailpage=59&cntnt01category_id=$1&cntnt01ret#urnid=59  [NC,L]
RewriteRule ^cms/category/([0-9]+)/(.+).thriplow index.php?mact=News,cntnt01,default,0&cntnt01detailpage=59&cntnt01category_id=$1&cntnt01returnid=59  [NC,L]

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

#Rewrites urls in the form of /parent/child/
#but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).thriplow$ index.php?page=$1 [QSA]

#RewriteCond %{HTTP_HOST} ^thriplow.org.uk$ [OR]
#RewriteCond %{HTTP_HOST} ^www.thriplow.org.uk$
#RewriteRule ^cms/category/([0-9]+)/(.+).thriplow index.php?mact=News,cntnt01,default,0&cntnt01detailpage=15&cntnt01category_id=$1&cntnt01returnid=15  [NC,L]

Code: Select all

<?php
# CMS Made Simple Configuration File
# Documentation: /doc/CMSMS_config_reference.pdf
#
$config['php_memory_limit'] = '100000000';
$config['process_whole_template'] = false;
$config['debug'] = false;
$config['output_compression'] = false;
$config['timezone'] = 'Europe/London';
$config['dbms'] = 'mysql';
$config['db_hostname'] = 'localhost';
$config['db_username'] = '***';
$config['db_password'] = '***';
$config['db_name'] = 'nexus';
$config['db_port'] = 0;
$config['db_prefix'] = 'cms_';
$config['persistent_db_conn'] = '';
$config['use_adodb_lite'] = true;
$config['root_url'] = 'http://thriplow.org.uk';
$config['ssl_url'] = 'https://thriplow.org.uk/cms';
$config['root_path'] = '/var/www/vhosts/thriplow.org.uk/httpdocs/cms';
$config['admin_dir'] = 'admin';
$config['previews_path'] = '/var/www/vhosts/thriplow.org.uk/httpdocs/cms/tmp/cache';
$config['uploads_path'] = '/var/www/vhosts/thriplow.org.uk/httpdocs/cms/uploads';
$config['uploads_url'] = 'http://thriplow.org.uk/cms/uploads';
$config['max_upload_size'] = 100000000;
$config['default_upload_permission'] = '664';
$config['use_smarty_php_tags'] = false;
$config['auto_alias_content'] = true;
$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.thriplow';
$config['query_var'] = 'page';
$config['image_manipulation_prog'] = 'GD';
$config['image_transform_lib_path'] = '/usr/bin/ImageMagick/';
$config['image_uploads_path'] = '/var/www/vhosts/thriplow.org.uk/httpdocs/cms/uploads/images';
$config['image_uploads_url'] = 'http://thriplow.org.uk/cms/uploads/images';
$config['ssl_uploads_url'] = '/uploads';
$config['locale'] = 'en-gb';
$config['default_encoding'] = 'utf-8';
$config['admin_encoding'] = 'utf-8';
$config['set_names'] = true;
$config['wiki_url'] = 'http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel';
?>
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Remove /cms folder from the url

Post by Rolf »

The .htaccess and the index.html in the server root must only contain the code I posted above. (changed the text above)

config.php and the default CMSMS .htaccess are in the website root.

In CMSMS 1.10+ the config.php only need to contain:

Code: Select all

<?php
# CMS Made Simple Configuration File
# Documentation: /doc/CMSMS_config_reference.pdf
#
$config['dbms'] = '';
$config['db_hostname'] = '';
$config['db_username'] = '';
$config['db_password'] = '';
$config['db_name'] = '';
$config['db_prefix'] = 'cms_';
$config['db_port'] = 0;
$config['root_url'] = '';
$config['timezone'] = '';
$config['default_encoding'] = '';
?>
And perhaps the url rewrite lines.
Try to add # before the other lines in your config.php, might help.

Grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

index.html is exactly as you suggested but I cant reduce the other 2 files down to what you suggested as that would break the site in functionality and pretty urls.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Remove /cms folder from the url

Post by Rolf »

This really should work:

Server Root
File #1 .htaccess

Code: Select all

RewriteEngine On
RewriteOptions inherit
RewriteBase /cms

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^cms(/?|/.+)$ /cms%{REQUEST_URI} [L]
File #2 index.html

Code: Select all

<__html>
<head>
<meta http-equiv="refresh" content="0;URL=http://www.cmsmadesimple.org/cms" />
</head>
</__body>
<__body>
</__html>
Website Root
File #1 config.php

Code: Select all

...
...
$config['root_url'] = 'http://www.cmsmadesimple.org';
...
...
$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.thriplow';
File #2 .htaccess The default CMSMS file from /doc folder
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

Strange, Most of the site works, its just the links on the news summaries and the articles list that break.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Remove /cms folder from the url

Post by Rolf »

i use it in combination with cgblog. it works there....
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

Would cgblog be better in my case than news module then?

Will I be able to do all the same things in my news page in cgblog?
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

I just thought Id include my news summary template:

Code: Select all

<!-- Start News Display Template -->

{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage}&nbsp;{$prevpage}&nbsp;
{/if}
{$pagetext}&nbsp;{$pagenumber}&nbsp;{$oftext}&nbsp;{$pagecount}
{if $pagenumber < $pagecount}
&nbsp;{$nextpage}&nbsp;{$lastpage}
{/if}
</p>
<br />
{/if}
{foreach from=$items item=entry}
{if $smarty.get.selectedauthor!= ""}{capture assign="selectedauthor"}{$smarty.get.selectedauthor}{/capture}{/if}
{if $selectedauthor}{capture assign="newsauthor"}<a href="{$root_url}news?selectedauthor={$entry->author|escape:'htmlall'}" class="postby">{$entry->author|escape:'htmlall'}</a>{/capture}{/if}
{capture assign="newsitem"}

<div id="bloginfo2">
	<table cellpadding="2" style="width: 100%">
		<tr>
			<td colspan="4" class="posttitle2"><table><tr><td valign="top"><img src="/cms/images/newsicons/page_green.png" border=0></td><td><span class="text"><strong><a class="links3" href="{$entry->moreurl}" title="{$entry->title}">{$entry->title|cms_escape}</a></strong></span></td></tr></table></td>
		</tr>
		<tr>
			<td><span class="postby"><img src="/cms/images/newsicons/calendar_view_day.png" border=0>&nbsp;{$entry->postdate|cms_date_format:"%d"}-{$entry->postdate|cms_date_format:"%b"}-{$entry->postdate|cms_date_format:"%Y"}</span></td>
			<td><img src="/cms/images/newsicons/tag_green.png" border=0>&nbsp;<span class="postby">{$entry->category}</span></td>
			<td>{if $entry->author}<img src="/cms/images/newsicons/vcard.png" border=0>&nbsp;<span class="postby"><a href="{$root_url}/news.thriplow?selectedauthor={$entry->author|escape:'htmlall'}" class="postby">{$entry->author|escape:'htmlall'}</a></span>
{/if}</td>
			<td>&nbsp;</td>
		</tr>
	</table>
</div>

{if $entry->summary}
	<div class="NewsSummarySummary"><br />
	<table cellpadding="0" style="width: 95%;margin: 0 auto;">
		<tr>
			<td class="lbq" style="width: 1px" valign="bottom">&nbsp;</td>
			<td class="cbq" style="width: 100%">
			<table cellpadding="10" style="width: 100%">
				<tr>
					<td class="summerycontent">{eval var=$entry->summary}<br /></td>
					<td class="rbq" valign="top" style="width: 30px;height: 100%">{cms_module module="TruetypeText" style="quote" text="”"}</td>
				</tr>
			</table>
			</td>
		</tr>
	</table>

	</div>

	<div class="NewsSummaryMorelink">
		<spam class="text">{$entry->morelink}</spam>
                <br />
	</div>

{else if $entry->content}

	<div class="NewsSummaryContent">
		<spam class="text">{eval var=$entry->content}</spam>
	</div>
{/if}

{if isset($entry->extra)}
    <div class="NewsSummaryExtra">
        {eval var=$entry->extra}
	{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
    </div>
{/if}
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
          {$field->name}:&nbsp;{eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}

<div id="hrline" style="align:center">&nbsp;</div><br />
</div>
{/capture}
{if $selectedauthor}
{if $newsauthor === $selectedauthor}{$newsitem}{/if}
{else}
{$newsitem}
{/if}
{/foreach}


{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage}&nbsp;{$prevpage}&nbsp;
{/if}
{$pagetext}&nbsp;{$pagenumber}&nbsp;{$oftext}&nbsp;{$pagecount}
{if $pagenumber < $pagecount}
&nbsp;{$nextpage}&nbsp;{$lastpage}
{/if}
</p>
{/if}

<!-- End News Display Template -->
and heres the summary list template that produces the article lists:

Code: Select all

<ul class="lists">
{foreach from=$items item=entry} <!-- you need to know what entry means in the link below -->
<li><a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">{$entry->title|cms_escape}</a>
</li>
{/foreach}
</ul>
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Remove /cms folder from the url

Post by Rolf »

You might want to look into your news template...

Code: Select all

<img src="/cms/images/newsicons/page_green.png" border=0>
Some stuff is kind of hardcoded to an url inside the subfolder. If you did the same for links in some templates thats your problem :)
This is the place for you to start digging.

Grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
swarfega
Forum Members
Forum Members
Posts: 174
Joined: Mon Sep 06, 2010 10:51 am

Re: Remove /cms folder from the url

Post by swarfega »

I guess I could change that to: <img src="[[root_url]]/images/newsicons/page_green.png" border=0>
Locked

Return to “The Lounge”