[solved]change static site to cmsms/file extensions/htaccess

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
ladyr0gue
Forum Members
Forum Members
Posts: 91
Joined: Fri Feb 17, 2012 4:25 pm

[solved]change static site to cmsms/file extensions/htaccess

Post by ladyr0gue »

At the moment I have a static html site which has mostly file extensions .html and two .php pages.
The plan is to change it to a cmsms site which I am working on on a local server.

At present if I type "http://www.mysite.com/page it shows the page the same as if I type in "http://www.mysite.com/page.html.

What I was wondering about is that currently search engines read all my links with the page extensions as all my internal links have the page extensions included. When I change over to cmsms I will need the old links "http://www.mysite.com/page.html to be directed to page "http://www.mysite.com/page or I will get broken links. How do I modify my .htacess file to do this or is there an easier way?
Last edited by ladyr0gue on Fri Apr 13, 2012 8:07 pm, edited 4 times in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: changing static site to cmsms, file extensions, htaccess

Post by calguy1000 »

CMSMS supports multiple routes to the same content page.

i.e: "http://mysite.com/index.php?page=alias (this will always work)
"http://mysite.com/index.php/alias (using internal pretty urls without a page extension)
"http://mysite.com/index.php/alias.html (using internal urls with a page extension)
"http://mysite.com/index.php/a/url/i/created.html (using internal urls with a page extension)
"http://mysite.com/index.php/a/url/i/created (using internal urls without a page extension)
"http://mysite.com/alias (using mod_rewrite without a page extension)
"http://mysite.com/alias.html (using mod_rewrite with a page extension)
"http://mysite.com/a/url/i/created (using mod_rewrite with a custom url for a content page)
"http://mysite.com/a/url/i/created.html (using mod_rewrite with a custom url for a content page and a page extension created).

The secret for a migrated site is:
a: configure a reasonable page extension in your config.php. In your case '.html' would probably be best. If your page extension on your static site was .html before, and you named your aliases properly this should handle 90% of the cases.
b: ensure that the rel=canonical stuff is in place properly so that the search engines know the true url to the page to ensure that search engines don't penalize you for duplicate content.
c: Use the cms_selflink, menumanager and other link mechanisms (don't create links yourself) so that all links within your website are created consistently.
d: Use .htaccess 301 or 302 rules to redirect all old links that you couldn't cover with the steps above to the new pages. This, in conjunction with the rel=canonical will allow anybody (or any search engine) following on an old link to your site to be directed to the correct page, and then see the rel=canonical link to know that the followed URL is the 'one true' url.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
ladyr0gue
Forum Members
Forum Members
Posts: 91
Joined: Fri Feb 17, 2012 4:25 pm

Re: changing static site to cmsms, file extensions, htaccess

Post by ladyr0gue »

Thank you for your quick reply,
Just to make sure I've understood you correctly,
on my cmsms site's config.php in the url setting I have put

Code: Select all

$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.html';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
Do I need to add .html to the aliases? as at the moment it doesn't seem to make any difference...

in my .htaccess I currently have

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,NE]
to rewrite the urls in the form of /parent/child/ - do I still need to implement rel=canonical and if so how do I do that? Sorry I've been away from the project for a while and seem to have forgotten everything :/

edit: realised i had an instance of

Code: Select all

$config['page_extension'] = '/'; 
as well in the config.php, removed that and now the pages are rewritten as .html as required, thanks :) - so for the two remaining .php pages I'll just 301 redirect them to the new 'pretend' .html versions.

Still unclear on how or where to implement rel=canonical though.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: changing static site to cmsms, file extensions, htaccess

Post by Dr.CSS »

In the <head> of default CMSMS template you should find...

{if isset($canonical)}
<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}
<link rel="canonical" href="{$content_obj->GetURL()}" />
{/if}
ladyr0gue
Forum Members
Forum Members
Posts: 91
Joined: Fri Feb 17, 2012 4:25 pm

Re: changing static site to cmsms, file extensions, htaccess

Post by ladyr0gue »

ah lovely. thanks. As I'm making my own template from scratch I'd missed that bit :)
Post Reply

Return to “CMSMS Core”