Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-15 18:23:50

LeeStewart
Archived Plugin Author
From: Boston, MA, US
Registered: 2005-07-25
Posts: 81
Website

Getting messy URL's without "index.php"? Maybe using mod_rewrite?

I’m in the process of revamping my blog and decided that my URLs should be in the format:

www.RandomOddness.com/section/id

The built-in options for non-messy URLs always seems to include the title, so I thought I’d try zem_rewrite. This sort of works, but I have trouble with comments and things. I guess I could go through all the code and use a zem_rewrite tag, but the admin pages don’t work properly either (clicking “view” after saving something I wrote, for example).

My current .htaccess looks like this (I think it’s the stock file that comes with TextPattern, with a small change to handle missing “images/titles” files):

#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} (.)images/titles(.)
RewriteRule ^(.*) – [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) – [PT,L]

RewriteRule ^(.*) index.php
</IfModule>

#php_value register_globals 0

Is there an easy fix? I thought I could use mod_rewrite, since I never want the users to see “index.php” in the URL (maybe do a 301 redirect?)

Thanks!
Lee


Monkeys could have written a better post..

Offline

#2 2009-02-15 20:53:10

LeeStewart
Archived Plugin Author
From: Boston, MA, US
Registered: 2005-07-25
Posts: 81
Website

Re: Getting messy URL's without "index.php"? Maybe using mod_rewrite?

Ack, I confused my thoughts when I wrote my original post. My goal is to get “messy URLs” without the index.php or “clean URLs” without the title.

The trick is getting the URLs to be consistent throughout the site. So something like one of these would be perfect:

www.RandomOddness.com/section/id
www.RandomOddness.com?s=123&id=456

I should know better than asking questions before my first cup of coffee…

Thanks,
o_o


Monkeys could have written a better post..

Offline

#3 2009-02-16 01:29:21

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Getting messy URL's without "index.php"? Maybe using mod_rewrite?

LeeStewart wrote:

Ack, I confused my thoughts when I wrote my original post. My goal is to get “messy URLs” without the index.php or “clean URLs” without the title.

Just select section/id/title URL rules for site, and take advance of Textpattern’s url rewriting; instead of using the title part in the url, you can instead only use section/id, and it works just fine, because the title isn’t used for anything.

So, you can link articles with section/id scheme when using section/id/title. You just have to make links “manually”, for example, <txp:section />/<txp:article_id />, and so on, instead of <txp:permlink />.

Offline

#4 2009-02-16 06:15:28

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Getting messy URL's without "index.php"? Maybe using mod_rewrite?

You are probably looking for the “Attach titles to permalinks?” advanced preference.

Offline

#5 2009-02-16 17:02:23

LeeStewart
Archived Plugin Author
From: Boston, MA, US
Registered: 2005-07-25
Posts: 81
Website

Re: Getting messy URL's without "index.php"? Maybe using mod_rewrite?

Okay, that’s number “one”.

I’m only allowed three stupid questions. When I ask my fourth, I have to wear a pink duncecap and dance to an Abba tune of your choice. Somehow I missed the “Attach titles to permalinks?” in the advanced preferences. Maybe it’s new, maybe I didn’t catch it when I read the docs, or maybe I ate too many paint chips when I was a child.

I turned off the zem_rewrite plugin, set up TextPattern to use a “Permanent link mode” of /section/id/title and then told TextPattern to not attach the ‘title’.

Everything looks great now, thanks!

Lee


Monkeys could have written a better post..

Offline

#6 2009-02-16 17:34:43

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Getting messy URL's without "index.php"? Maybe using mod_rewrite?

wet wrote:

You are probably looking for the “Attach titles to permalinks?” advanced preference.

Oh, I don’t understand the explanation about this option on Textbook.
Rob (or anyone), care to explain?

Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2009-02-18 18:11:40

LeeStewart
Archived Plugin Author
From: Boston, MA, US
Registered: 2005-07-25
Posts: 81
Website

Re: Getting messy URL's without "index.php"? Maybe using mod_rewrite?

wet wrote:

You are probably looking for the “Attach titles to permalinks?” advanced preference.

maniqui wrote:

Oh, I don’t understand the explanation about this option on Textbook.
Rob (or anyone), care to explain?

As I understand it, “non messy” permalink URLs end with the title string (actually the ““URL-only title” value that’s built when you create a post). If you choose “no” for “Attach titles to permalinks?”, then the URL looks like what you selected in “Permanent link mode” – but without the title.

Everything is working great on my site, thanks for the help!

Lee


Monkeys could have written a better post..

Offline

Board footer

Powered by FluxBB