changing templates and htaccess behavior

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

changing templates and htaccess behavior

Post by Timbalu »

Hi

I get my pages like

Code: Select all

serendipity/pages/myplugin.html
which works perfectly. [1.0.1]

I activated the template chooser plugin. After changing the templates the url looks like,

Code: Select all

serendipity/index.php?pages/myplugin.html
but does not link to the plugin. Its not a matter of my plugin I think, it must have to do with the .htaccess file, which includes all normal rewrite engine ON inputs.

Is there a way to change the behavior with htaccess? I just need to get rid of the 'index.php?'.

Regards, Ian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Post by Timbalu »

someone any ideas?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Did you change your "URL Rewriting" option in the s9y configuration? This change cannot be related to the template chooser plugin.

What's your URL?

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/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Post by Timbalu »

Hi Garvin

Yes thats what I said... it seems like a matter of .htaccess
I did not change my "URL Rewriting" option in the s9y configuration,
see examples:

Regards, Ian

Code: Select all

/s9y/pages/imprint.html [Template 1]
/s9y/index.php?pages/imprint.html [url look in Template 2]
changing template this will not get redirected and shows just the start page

Code: Select all

/s9y/pages/contact.html [Template 1]
/s9y/index.php?pages/contact.html [url look in Template 2]
changing template this will not get redirected and shows just the start page

Code: Select all

/s9y/archives/269-Die-letzte-Fahrt.html [Template 1]
/s9y/index.php?archives/269-Die-letzte-Fahrt.html [url look in Template 2]
changing template this will get redirected and shows the correct page!!

Code: Select all

/s9y/plugin/bookmarks [Template 1]
/s9y/index.php?plugin/bookmarks [url look in Template 2]
changing template this will not get redirected and shows just the start page

Code: Select all

/s9y/archive [Template 1]
/s9y/index.php?archive [url look in Template 2]
changing template this will not get redirected and shows just the start page

.htaccess

Code: Select all

# BEGIN s9y
ErrorDocument 404 /s9y/index.php
DirectoryIndex /s9y/index.php

RewriteEngine On
RewriteBase /s9y/
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)? index.php?url=admin/ [L,QSA]
RewriteRule ^archive$ index.php?url=/archive [L,QSA]
RewriteRule ^categories/([0-9]+) index.php?url=/categories/$1 [L,QSA]
RewriteRule ^(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ rss.php?file=$1&ext=$2
RewriteRule ^plugin/(.*) index.php?url=plugin/$1 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$1 [L,QSA]
RewriteRule ^authors/([0-9]+) index.php?url=/authors/$1 [L,QSA]
RewriteRule ^index\.(html?|php.?) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]

<Files *.tpl>
    deny from all
</Files>

<Files *.sql>
    deny from all
</Files>

<Files *.inc.php>
    deny from all
</Files>

<Files *.db>
    deny from all
</Files>

# END s9y
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

What is Template 1 and Template?

URLs like "index.php?archives/..." will ONLY be created if "URL Rewriting" in your s9y configuration is set to "NONE". Or if any of your plugins or code sets

Code: Select all

$serendipity['rewrite'] = 'none';
Check your serendipity_config database, see what "rewrite" is set to there.

Best 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/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Post by Timbalu »

checked!
name value authorid
rewrite rewrite 0

Template 1 and 2 mean just examples for real templates, which can be choosen in the template dropdown sidebar plugin.

The failure just appears when I change between the templates.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Are you speaking only of the URL that you get, when you are viewing an entry and then changing the template? If so: The URL needs to use index.php?XXX for the target of the form that the templatedropdown uses. It is not allowed to send POST variables to URLs that are modified via Apache Errorhandling. Thus, we POST the values to the globally recognized URL.

In that case, it's not a bug - technically it only really works well that way.

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/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Post by Timbalu »

Ok, but if I am in template 1 inside /pages/imprint.html and I change the template the new template opens the startpage and not /pages/imprint.html.
As described it works with normal article entries.
So we just need to get rid of the 'index.php?' in the url and the behavior will be ok.

Ian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

What's your URL?

We cannot get rid of index.php. I explained why. :)

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/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Post by Timbalu »

Hi Garvin

did you see what I meant ??
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I didn't see any URL for your page, so I tried it on my own. For instance: http://judebert.com/wasted_youth/archiv ... c-Car.html works fine with my default template. Then I used the template dropdown to change to Blue Haze; that worked fine, too, even though it uses the index.php?XXX method (because the template changer needs to send a POST variable, just like Garvin mentioned).

No problem with more complex themes, such as Ladybug, either.

Figuring it might be something with permalinks (as opposed to the archive link I used before), I tried the same thing on http://judebert.com/wasted_youth/EV/Aftermath.html. That demonstrates the same error I think you're describing: the index.php?XXX version tries to use my permalink for the XXX, and Serendipity gets confused. Maybe because there's no article ID. And when Serendipity gets confused, it sends you to the front page.

So, if you're using permalinks, my first suggestion at a workaround would be to change the permalink to include an article number, right up front.

Perhaps if we can see the problem on your site we'll be better able to understand it and produce a solution?
Judebert
---
Website | Wishlist | PayPal
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Post by Timbalu »

Oh sorry!

Garvin and I allready worked out a solution, changing functions_permalinks.inc.php and serendipity_plugin_templatedropdown.php. I think Garvin made a change for the public.

Regards, Ian
Post Reply