Welcome to WebmasterWorld Guest from 54.167.252.62

Forum Moderators: phranque

Message Too Old, No Replies

Static HTML Pages Without File Name Extensions

Moving CMS to static pages. 301 redirect only option? If so, which method?

     
8:29 am on Jan 23, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I am moving some pages, that up until now have been in a CMS package, into static HTML files.

Obviously, I want to keep the same URL structure. The CMS had been using 'SE friendly' URLs. However, the CMS had also been using 'pages' without file name extensions.

So, for example:

http://www.example.com/thing/green-widgets/pagename

Obviously, I can simulate part of this structure with physical directories, but the html file itself needs an extension or my web server (Linux, CPanel hosted) just displays the pages as code.

Is there a way for me to keep the file structure exactly as it is, or will I have to create new pages and 301 redirect?

* On a side note, annoyingly, the CMS also displayed a duplicate page if the trailing slash was used. E.G. http://www.example.com/thing/green-widgets/pagename/

So I could use this opportunity to 301 redirect all pages to the trailing slash directory version of the URL (and stick an index.html age in the directory). However, this trailing slash url format was never linked to, so ideally I would prefer to keep the structure exactly as it is and redirect the 'directories' to the pages.

I know there are plenty of code examples as to removing file extensions, However, I should point out that these pages are only part of the site. There are hundreds of other static pages, with extensions, that I want to keep as they are.

8:51 am on Jan 23, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



OK. This is what I have done. But I'm not sure that this was the best option, so be interested in any views.

I created a new MIME type text/html and called the extension .ttt

Then I added the following to .htaccess. I'm hoping that this should only affect (i.e. remove the file extension) of files with a .ttt extension?

RewriteCond %{REQUEST_filename} !-d
RewriteCond %{REQUEST_filename} !-f
rewriterule ^(([^/]+/)*[^./]+)/?$ /$1.ttt [L]

I'm still finding that the trailing slash version of the URL is loading the page, as does the .ttt version. But I can always 301 redirect that, which is a pain, but there's only a few dozen pages.

Does anyone see anything horrible in what I've done, or suggest any better options?

 

Featured Threads

Hot Threads This Week

Hot Threads This Month