Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-12-04 00:15:25

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

[plugin] [ORPHAN] zem_rewrite: configurable clean URLs

zem_rewrite parses and produces configurable clean URLs for permalinks, section and category lists. Features:

  • Eliminates the need for editing .htaccess or uploading files when sections are created and edited
  • Not dependent on a particular rewrite method, so it can be adapted to IIS
  • Can produce URLs in many forms, e.g:
  • /section/category/25/my-article-title
  • /section/2004/09/28/25/my-article-title
  • /section/2004/09/28/category/25/my-article-title
  • /section/category/

Download and documentation here

I haven’t been able to try it on IIS, so perhaps someone who knows IIS rewrite magic can adapt it and post the results here.

NB – the plugin provides several tags for producing URLs using the configured scheme. Don’t expect older tags and plugins to magically start producing links with the new scheme, however.

The plugin includes two functions (zem_format_url and zem_format_link) for creating URLs and links using the configured scheme. Other plugins can call these functions – I’ll post some code demonstrating how later.

Oh, and if you’re using the zem_rewrite plugin, you might have to temporarily disable it on some pages. I’m working on an update that’s compatible with zem_rewrite.


Alex

Offline

#2 2004-12-04 01:18:24

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

I should point out that the plugin will happily produce and accept URLs that are ambiguous, conflicting or nonsensical. If your ‘article’ URL scheme doesn’t include the {article} parameter, don’t expect articles to show up.

Similarly, beware of schemes that are indistinguishable. For example, if you use:

$uri_scheme['category'] = '{category}/';
$uri_scheme['section'] = '{section}/';

..zem_rewrite won’t be able to tell whether the url http://example.com/foo/ refers to foo as a section or as a category.


Alex

Offline

#3 2004-12-04 01:43:51

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Wow. Bravo, zem!

Offline

#4 2004-12-04 03:20:23

misterk
Member
From: Morris, MN
Registered: 2004-02-24
Posts: 77
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Marvelous. The problem is now I’m so used to textpattern url’s that I kind of like them :)

Offline

#5 2004-12-04 05:07:53

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Does this require anything like the faux section files? (e.g. I have to use rewrite rules because the other .htaccess methods did not work.)

Pretty cool though. Of anything I’ve seen this ought to go into the base distribution.

Offline

#6 2004-12-04 07:03:39

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

> Remillard wrote:

> Does this require anything like the faux section files?

Nope. Just one of several different forms of rewrite magic; everything else is done in the plugin. You can even use Errordoc handling if mod_rewrite is unavailable.


Alex

Offline

#7 2004-12-05 01:48:08

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

I’ve updated this to version 0.3. The new version includes some improved rewriterules, and should work on more server types.


Alex

Offline

#8 2004-12-05 02:30:49

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

..and 0.4. This adds support for article url_title without the ID (as in /section/my-article/ or /section/category/my-article/ instead of /section/123/my_article). It’s undocumented because it’s a bit ugly and has some limitations.

To use it, add this URL scheme above the category scheme and below the other article schemes:

$uri_scheme['article_urltitle'] = '{section}/{url_title}/';

You can create permalinks in that format with this tag:

<txp:zem_permlink scheme="article_urltitle">foo</txp:zem_permlink>

However, this requires that:

1. Your articles have the URL only title field set, and
2. You’re not clashing with clean category URLs (the URLs /section/category/ and /section/url-title/ are indistinguishable).

Last edited by zem (2004-12-05 03:12:42)


Alex

Offline

#9 2004-12-05 04:16:38

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Very nice. This will definitely help in generating nicer clean URLs for static pages. Now I just wish I could get it working right.

First, if I have TXP installed at the root of my webserver, does the rewrite rule go in the .htaccess file in my root directory or in my textpattern directory?
Edit: Pretty sure I’m correct in having this in my root directory.

Then, for example, say I write an article in section about and give it a category of this. If I go to site.com/about/this should I be able to see that article?

Thanks for any help.

Edit Again:

Everything working fine now. A couple tips.

  1. I don’t know much about mod_rewrite rules but I did learn that I needed to remove the rules that were part of the default TXP install to get this to work.
  2. If you already have existing section files, remove them.

Last edited by wilshire (2004-12-05 04:29:01)

Offline

#10 2004-12-05 05:32:27

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

> wilshire wrote:

> Everything working fine now. A couple tips.

Indeed, sensible advice that really should be part of the documentation. I’ll mention that in the next release.


Alex

Offline

#11 2004-12-06 14:17:57

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

I’m in the process of upgrading a site done in php/html to use TXP. I’m usually able to do this while leaving the existing site intact since my pages use the .html extension and I can use index.php to go to the new TXP index page.

However, if I try to use the rewrite rules for this plugin when I go to my root (www.mysite.com) instead of bring up my index.html page I get the TXP index.php.

I tried adding DirectoryIndex index.html to my htaccess but to no avail.

Any suggestions on a work around for this?

Offline

#12 2004-12-06 16:01:23

Tae
Member
From: nyc
Registered: 2004-08-25
Posts: 20

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

i dont know much about .htaccess and such but i recently switched a flat site to txp and found that it was very easy to work on a subdomain (dev.mysite.com) during development and then just “throw the switch” when i was done with minimal fuss.

~

cool plugin btw. i plan to use it on my next site and then retro-fit it into my current one when i’m comfortable with it.

Offline

#13 2004-12-06 18:04:13

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

And to answer my own question, I added this to the top of my .htaccess file and when I go to mysite.com I’m back to getting my trusty old index.html.
<code>
AddType application/x-httpd-php .html .php
RewriteRule ^$ index.html [L]
</code>

Last edited by wilshire (2004-12-06 18:05:10)

Offline

#14 2004-12-10 03:47:56

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

When using zem_permlink it doesn’t seem to take into account what Section the article belongs to when clicking on it from the home page. I have a section called words that displays on the homepage and when I click on permalinks from there I get the Url of /default/article-id/article-title/ instead of /words/article-id/article-title/ The same article when clicked on from the words section page will give me the right section in the URL.

Do I have something setup wrong or is this a limitation of the system? I’m pretty much using everything in the default way. even if the section part is not totally fleshed out it is still very nice not to have to deal with section files.

Last edited by hakjoon (2004-12-10 03:48:59)


Shoving is the answer – pusher robot

Offline

#15 2004-12-10 05:15:32

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

It’s a bug. Working on a new releas.


Alex

Offline

Board footer

Powered by FluxBB