Page 1 of 1

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

Posted: Thu Apr 12, 2012 5:17 pm
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?

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

Posted: Thu Apr 12, 2012 5:31 pm
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.

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

Posted: Thu Apr 12, 2012 7:07 pm
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.

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

Posted: Thu Apr 12, 2012 7:34 pm
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}

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

Posted: Thu Apr 12, 2012 7:40 pm
by ladyr0gue
ah lovely. thanks. As I'm making my own template from scratch I'd missed that bit :)