Rewrite rule improvements nad 301 sugestion

Creating and modifying plugins.
Post Reply
Greyer
Regular
Posts: 10
Joined: Fri Apr 04, 2008 11:18 pm
Location: Varna, Bulgaria
Contact:

Rewrite rule improvements nad 301 sugestion

Post by Greyer »

Hi,

Is there a way for me to add a rule in the rewrite functionality so that it converts capital letter to small ones? Also is it possible to ignore punctuation in the title so that they are not added in the URL?

In this post for example - greyer.atsense.com/archives/Maybe-....html

I cann't use the custom permalink plugin since it can't use the /archive/ structure and I do want to be able to use punctuation in the title.

Also could someone create a plugin to create 301 redirects as I can't find any and I suck at programing?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Rewrite rule improvements nad 301 sugestion

Post by garvinhicking »

Hi!

That mechanism must be changed inside the file include/functions_permalinks.inc.php

The first function serendipity_makeFilename must be changed so that before the ending line "return $str;" you add this line:

Code: Select all

$str = str_replace('.', '', strtolower($str));
About 301 redirection, I can sadly only point out to search google for "rewriterule 301 .htaccess" to find examples on how to craft those.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Greyer
Regular
Posts: 10
Joined: Fri Apr 04, 2008 11:18 pm
Location: Varna, Bulgaria
Contact:

Post by Greyer »

I did that and it worked, but then I noticed a different problem - I can't find post with one word titles. The articles do appear on the homepage but when I click for the detailed review the server couldn't find it - "No entries to print".

I returned the original version of the file and tried again with a new post - same thing.

In case you are wandering I am running Serendipity 1.2, so it could be a bug in the older version which you already fixed. Let me know if that's the case.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

This might happen when you do not use %id% in the URL and no permalink path prefix. How exactly did you configure your URLs and permalink paths?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Greyer
Regular
Posts: 10
Joined: Fri Apr 04, 2008 11:18 pm
Location: Varna, Bulgaria
Contact:

Post by Greyer »

I think I just removed the %id%

Currently my URLs look like this - mysite.com/archives/post-title.html

I am pretty new to this stuff so please bare with me :oops:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

The trouble is that s9y interprets single-word archive links as Month/Yearch archives. It only interprets it as a single posting, if at least one "-" occurs.

There are a couple ways to try to remove that situation:

1. Re-insert %id% into the URL (it will also speed up your blog!)

2. Insert a hardcoded "-" in the title of each posting, like /archives/post-%title%.html (or maybe /posts/archives/%title%.html, that could work)

3. Try to change the permalink for an entry to /postings/%title% while leaving the archive path (seperate config option) still set to "archive". This might have an impact on other parts of s9y, but I'm not sure.

4. Do not use blog entries with one word ;-) ;)

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Greyer
Regular
Posts: 10
Joined: Fri Apr 04, 2008 11:18 pm
Location: Varna, Bulgaria
Contact:

Post by Greyer »

Yea, I am already using the 4th option, but thought I should let you know ;)

How does the %id% help speed up my blog? I don't have any complains yet but I have ~10 posts so far so there is not much the server could choke on. But if removing the id from the URL is going to create problems in the future I might as well bring it back.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
How does the %id% help speed up my blog? I don't have any complains yet but I have ~10 posts so far so there is not much the server could choke on. But if removing the id from the URL is going to create problems in the future I might as well bring it back.
When an ID is contained in the URL, s9y immediately knows what to lookup. Without the ID, s9y needs to perform an additional database lookup for the current URL. This does not impact performance THAT much, but the fewer queries that need to be executed, the faster the blog.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply