Help - Search - Members - Calendar
Full Version: clean path
Movable Type Community Forum > Additional Resources > Tips and Tricks
zachariah
Hi,

I am hoping that there is some way to tweak MT so that the perm address (or at least the archived address) of postings are of the form (year-month-day/hhmm):
http://~site~.tld/2003-03-04/1234/
or
http://~site~.tld/2003-03-04/1234/topic_title/

rather than
http://~site~.tld/2003-03-04/1234/topic_title.html

Any ideas?

I was thinking that there must be a way internally to do this, otherwise does anyone have any expertise with apache url rewriting?

thanks,
Zachariah
tubedogg
You could do this one of two ways:
1) Use a URL that includes some sort of individual entry marker, i.e. the hhmm that it was posted, or the entry ID, as the directory name and use index.html (or index.php or whatever) as the filename. (I use the entry id on geeksblog, and the URL in MT looks like this:
http://backlog.geeksblog.com/yyyy/mm/dd/entryid/index.php
but you can type
http://backlog.geeksblog.com/yyyy/mm/dd/entryid
to get the same thing.)

2) URL rewriting. This would be a really simple way of doing it as well...simply create a file named .htaccess and put it in the base directory where your achive directories are, with this in it:

RewriteEngine On
RewriteRule +)/([0-9-]+)/([0-9-]+)/([a-zA-Z0-9._-]+)]http://([a-zA-Z0-9.-_]+)/([0-9-]....9._-]+) http://$1/$2/$3.html

You'd put your files in directories as such:
http://site.tld/1/2/3
1 - any numerals and/or the dash character can go there (the entry date in your example URLs)
2 - any numerals and/or the dash character (the time in your example URLs)
3 - the entry title, dirified - any numerals, any characters a-z and A-Z, and the characters . - and _ can go there

(untested but should work - let me know if it doesn't)

Doing it this way, you can name your entry files topic_title.html but the user can type the URL without the .html and will see the correct page (and the URL he sees in his address bar will not have the .html).

3. Assuming your server will parse a non-directory file as HTML, just don't give the files an extension and the URL looks clean without any bother.
zachariah
Thanks!

QUOTE
1) Use a URL that includes some sort of individual entry marker, i.e. the hhmm that it was posted, or the entry ID, as the directory name and use index.html (or index.php or whatever) as the filename. (I use the entry id on geeksblog, and the URL in MT looks like this:
http://backlog.geeksblog.com/yyyy/mm/dd/entryid/index.php
but you can type
http://backlog.geeksblog.com/yyyy/mm/dd/entryid
to get the same thing.)


I like this way the best (above).  I am not sure how to make it do this though.  I do understand that I set the archive directory to be the root of the site (and I know where to configure that).  

But I don't know how (where) to make it so that the entry-id is a directory rather than the name of an html file.  

I will keep playing with it untill I find it or untill someone points it out to me.
gramcracker
I just make my permalinks like this:

CODE
<a href="past/<$MTEntryID$>/">link it</a>


And have individual archive templates setup like this:

CODE
<$MTEntryID$>/index.php
zachariah
ok so I finally found the burried page called "Archiving | Configuration"

I just want the string that will make it so that my individual archives are:
http://www.(domain).com/yyyy/mm-dd/index.shtml


thanks!
cpuwiz
This should do the trick:

CODE
<$MTEntryDate format="%Y/%m-%d"$>/index.shtml
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.