Long and Short Permalinks at the same time?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
johncanary
Regular
Posts: 116
Joined: Mon Aug 20, 2007 4:00 am
Location: Spain
Contact:

Long and Short Permalinks at the same time?

Post by johncanary »

Hello everybody!

Can I have long and short Permalinks working at the same time? I would like to have a shortcut URL as deep link for the post. E.g.:

Code: Select all

'http://blog.fcon21.biz/2007-08/55-Tools-to-Find-Out-How-People-Search'
and one of the following

Code: Select all

'http://blog.fcon21.biz/2007-08/55' or
'http://blog.fcon21.biz/55' or
'http://blog.fcon21.biz/index.php?id=55
Should deliver the posting article with a 200 OK HTTP Status Code of course. Something with 'index.php' would be fine, too.

Any ideas?
You may also write a reply, if you think this is a silly request. Let me know.
----
My setup for my S9Y Blog atblog.fcon21.biz

* URL Rewriting: "Apache mod_rewrite"

* .htaccess not manually modified (standard setup)

* Permalink for post:

Code: Select all

%year%-%month%/%id%-%title%
The text in the Admin Interface suggests that you should keep the %id% identifier in the URI for performance reasons. Okay, I did that. Otherwise I would have left %id% out.

Adios, Yours
John
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Long and Short Permalinks at the same time?

Post by garvinhicking »

Hi!

http://yourblog/index.php?serendipity[id]=XXX will always work together with the full permalink.

Additional to that you'd need to setup custom mod_rewrite rules in your .htaccess file, like

RewriteRule ^/([0-9]+)$ index.php?serendipity[id]=$1 [L,QSA]

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/
johncanary
Regular
Posts: 116
Joined: Mon Aug 20, 2007 4:00 am
Location: Spain
Contact:

Re: Long and Short Permalinks at the same time?

Post by johncanary »

Hello Garvin!
Thanks for the quick answer. But part one does not work.
garvinhicking wrote:http://yourblog/index.php?serendipity[id]=XXX will always work
I tried it on two of my S9Y installations AND on yours at garv.in/serendipity.
Same result: e.g. http://garv.in/serendipity/index.php?se ... y[id]=1169

Brings the blog's home page with all entries AND the comments, trackbacks showing as well. ?????????? Before I tried on your blog I checked my entries.tpl (since I changed some in there), but did not see anything suspcious (but how could I tell.)

What could work for me now.
I found a ReWrite Rule in .htaccess that could do the job, if I modify it or add a modified version of it.

Code: Select all

RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
%id% seems to be the only parameter to the entry in that URL, therefore I assume that it is a quick DB lookup and as good as the long version with the id.

I was successful by using, e.g. http://garv.in/serendipity/1169-p.html

Adios
John
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Long and Short Permalinks at the same time?

Post by garvinhicking »

Hi!

Oh, you're right. Indeed the s9y core doesn't/didn't support this. I've just patched this in our SVN core:

http://svn.berlios.de/viewcvs/serendipi ... /index.php

So if you update that piece of code, it will also work for you. Otherwise, you could use that "X-article.html" rewrite, yes.

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/
johncanary
Regular
Posts: 116
Joined: Mon Aug 20, 2007 4:00 am
Location: Spain
Contact:

Thank you - It works!

Post by johncanary »

Good Morning!

Thanks so much for the quick PATCH. I applied it, works nicely. :D
As you know some email clients insert line breaks in long URIs.
This solution makes it possible to embed nice, short links without any
third party tool
.

I am using the following additional rewrite rule (just that anyone can adopt it easily).

Code: Select all

RewriteRule ^(p|post)([0-9]+)/?$ index.php?p=$2 [NC,L,QSA]
Then I can call the article directly with, e.g. let us call article with id 34:

Code: Select all

http://yourblog-dot-whatever/p34 or
                         .../p34/ or
                         .../post34 or
                         .../post34/
All you need then, is a short domain name.
Adios
John :D

P.S.: This request of mine goes back to a post in Guy Kawasaki’s Blog - The Top Ten Stupid Ways to Hinder Market Adoption.
Number 2 is "Long URLs". That's why, I wanted this.
Long URL are great in one way, but being able to easily shortcut them is also essential.
Thanks again. This makes S9Y more useful.
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
johncanary
Regular
Posts: 116
Joined: Mon Aug 20, 2007 4:00 am
Location: Spain
Contact:

Google Ads are not showing

Post by johncanary »

I just noticed that the Google AdSense Ads are not showing, if I call the page with the
short version of the URI. Strange, I don't have any explanation for it. No problem with
the full URL.

No, Link Block, No Text Ads.

E.g.: http://blog.fcon21.biz/p64

There should be Ads in the left sidebar and below the extended entry. All well, with the
long version of the URI. :?:

Probably someone has an idea?
I also will post it in the AdSense Forum and report any valuable feedback.

Yours
John
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Google Ads are not showing

Post by garvinhicking »

Hi!

Uhm, the page looks the same if I use the short or the long URL (using FF 2.0)!

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/
johncanary
Regular
Posts: 116
Joined: Mon Aug 20, 2007 4:00 am
Location: Spain
Contact:

It's A Google AdSense Issue

Post by johncanary »

Good Morning!

Yes, I got Ads for both versions, too for /p64 this morning, but not for /p63. It seems to be independent from browser anyway. I observed it with IE, Mozilla, Firefox on Windows and Linux. I made a screenshot of the complete page, but don't post it here, because it's 400KiB

It is most likely an AdSense issue. I wont' persue this anymore. I am using the long version of the url as much as possible anyway. Simply Google is used to have keywords in the URI for that domain or it runs out of Ads, if you show the same page often. Something like that. I had the Ads dissappear on the long version for the URL as well, after reloading multiple times.

It is definitely not a S9Y issue.

I downloaded the XHTML source with "wget" on the console for the long and short URL and compared it. Same byte count, same HTTP headers, only difference are two seperate values for a 'serendipity[token]', but that should not have anything to do with it.

Adios
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
Post Reply