Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-12 20:42:36

december76
Member
From: Malmö, Sweden
Registered: 2004-05-18
Posts: 45
Website

Help with mod_rewrite

Hi.

I’, in dire need of help with a little mod_rewrite magic in the .htaccess file. I’m using the standard one currently, but need to make some modifications in order to accomplish the following:

Articles using the old url scheme http://hertze.com/article/211/fake-title need to be concerted to the new scheme http://hertze.com/blog/fake-title.

I don’t now much about mod_rewrite (or regexp), and honestly have no clue. But I’m sure this is quite simple if you know what you’re doing.

Please help. Anyone?

/Joakim

Offline

#2 2007-03-12 21:31:31

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Re: Help with mod_rewrite

If the old scheme http://hertze.com/article/211/fake-title works, you don’t need any mod_rewrite magic!

Just open the txp admin tab, point to preferences. Choose “section/title” as permanent link mode.
After you did that the article with url-title fake-title saved in section blog is avaible under http://hertze.com/blog/fake-title.

Offline

#3 2007-03-12 22:15:03

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Help with mod_rewrite

If you need the old URI to be smartly redirected to the new ones, there’s a plugin: Redirect Pro.

Offline

#4 2007-03-13 07:46:24

december76
Member
From: Malmö, Sweden
Registered: 2004-05-18
Posts: 45
Website

Re: Help with mod_rewrite

Bastian wrote:

If the old scheme http://hertze.com/article/211/fake-title works, you don’t need any mod_rewrite magic!

Well, actually this didn’t work for me. Since the section “article” no longer exists the old URI scheme breaks. I suppose Redirect Pro v1 would have solved the problem, but it does seem a bit overkill for this simple task. And I would then have missed this learning experience ;-).

I scrapped together a mod_rewrite rule from bits and pieces scattered across the Internet and ended up with a .htaccess file looking like this:

RewriteBase /
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^artikel/([0-9]+)/(([^/]+))?$ blogg/$2 [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>

This worked for me — at least. Thank you all for your input.

Offline

Board footer

Powered by FluxBB