Having a file extension of .htm

Permalink
Hello,

I have a client who is insisting on keeping their current sites file name structure, which are .htm, can I achieve this in C5? Something I can set in the config? Thanks!

sarah3585
 
jmonroe replied on at Permalink Reply
jmonroe
Unfortunately, there isn't anything I know of considering concrete is built using php language and php language needs php extensions to work.
JohntheFish replied on at Permalink Reply
JohntheFish
You can set up aliases for C5 pages to catch your old page paths, or use URL director.http://www.concrete5.org/marketplace/addons/url-director/... to manage it centrally.

This takes care of the paths.

For the .htm or .html extensions, if URL director doesn't handle them you can map them using .htaccess re-writes.
Mainio replied on at Permalink Reply
Mainio
Seems like JTF was faster, good suggestions as well.

But I believe simple .htaccess magic won't really do the trick because of how the request class parses the request path. That can be configured a bit (=might get it working with some specific settings) but it still doesn't automatically change the URL structure in c5.
Mainio replied on at Permalink Reply
Mainio
There isn't a setting for this but this is definitely achievable. You'll need to rewrite all the links in your content-blocks, autonav blocks and page list blocks to build the URLs in the desired format. After this, override the /libraries/request.php class to parse the URL path correctly from the new format.

[EDIT] Probably it's enough to override the /helpers/navigation.php which usually builds the URLs.

Of course, this requires you to enable pretty URLs from concrete5 which allows you to pass any requests paths in any format to concrete5.

However, this isn't the usually suggested method here and quite obviously, it isn't the easiest path out there.

Usually people just suggest putting these old URLs as additional paths to the pages that need to refer to the old pages. Concrete5 already has internal functionality to redirect the old pages to the new ones through this functionality.

It also uses 301 redirects, so Google will quite fast catch up with the updated URL paths.

Best,
Antti / Mainio
sarah3585 replied on at Permalink Reply
sarah3585
Hi all. I have already strongly suggested using 301s, but it's good to know there might be (even though it's quite painful) way of doing it if heals are really dug in.
Mainio replied on at Permalink Best Answer Reply
Mainio
Just FYI, I haven't really played that much with the apache rewrite engine myself, so just out of interest I thought I'd give it a try.

I think this should do the rewriting part (or at least some of it):
# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*).htm$
RewriteRule ^(.*)\.htm$ $1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
# -- concrete5 urls end --


(make sure the RewriteBase is correct for you, the above one is for server root)

So the thing you need to add to the default concrete5 rewrite rules are these two lines:
RewriteCond %{REQUEST_URI} ^(.*).htm$
RewriteRule ^(.*)\.htm$ $1 [L]


And this would leave you with re-writing the urls in correct form. I believe my initial suggestion of overriding the /helpers/navigation.php class would probably work out most of the URLs.

Best,
Antti / Mainio
sarah3585 replied on at Permalink Reply
sarah3585
Wow thanks for going the extra mile! Very much appreciated
Mainio replied on at Permalink Reply
Mainio
By the way, also wrote this:
http://www.concrete5.org/documentation/how-tos/developers/.html-or-...

Please note, it's not a complete solutions, I've noticed some issues with it. But if you apply it only outside dashboard / other single pages, I believe it should work fine.

Antti