Template lost when changing path or permalink: workaround

Found a bug? Tell us!!
Post Reply
mintaka
Posts: 2
Joined: Wed Jul 31, 2013 8:41 pm

Template lost when changing path or permalink: workaround

Post by mintaka »

Serendipity 1.7, Apache 2 and PHP 5.3.2-1

I first made a test install with the default settings, in directory "serendipity/". When I decided to keep the software I played around with the permalink structure per URL-rewriter (settled on %id%/%title%) and set up a virtual host on the server. Configured the relative path in s9y to "/" but kept it in the serendipity/ directory on disk. All worked except that at some point in the process (changing forth and back), the image files went missing. So basically it showed text only, with styles applied but without any graphics. With the admin panel, all style was gone. Sorry I can't repeat the process as I can't tell for sure what exactly I did when it happened.

Took me a while inspecting what was going wrong. I found that it served the index.html content for every file! The logical conclusion: there's something wrong with the rewriting that s9y does, not with my own. There's this line in .htaccess:

Code: Select all

RewriteRule ^([0-9a-z\.\_!;,\+\-\%/]*/[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
which will redirect any request to "index.php?/path/to.file" but s9y seems to have a problem finding the right file, thus falling back to index.php. In my case, it is safe to remove that line, as it is bogus, and this made it work.

For the same reason, I guess, the admin stylesheet stopped working:

Code: Select all

RewriteRule ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 [L,QSA]
I changed this to

Code: Select all

RewriteRule ^(serendipity\.css|serendipity_admin\.css)$ templates/default/admin/style.css [L,QSA]
which is a crude hack (hard-coded path) but now at least the admin panel has style again.

Stylesheet URL in the HTML that is served is

Code: Select all

http://blog.[domain].net/index.php?/plugin/categorytemplate_default
and 
http://blog.[domain].net/serendipity_admin.css 
/templates/default/admin/pluginmanager.css
on the main page and with the admin panel, respectively.

Because most of the rewrite lines do a rewrite to "index.php?url=*", I guess that there are other similar errors waiting but I didn't test all the features yet.

hth,
Mintaka
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Template lost when changing path or permalink: workaroun

Post by Timbalu »

In my eyes you are definitely digging and barking the wrong tree, changing the Serendipity root htaccess file, since this will get even worser over time for sure. Also your changes will get lost from time to time, when changing some config settings in the backend.
You will not be happy with that!

Since you are still at the beginning, I'd say: Start from scratch now after having set up your host. You may backup the database first and changed files first, to put this in afterwards. This will definitely be the better and shorter way!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
onli
Regular
Posts: 2829
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Template lost when changing path or permalink: workaroun

Post by onli »

@mintaka: Thank you very much for the report. It's a pity you can't reconstruct how that Bug occured, it would be very interesting to fix it.

Make sure that the settings under path are correct (backup the working .htaccess first). The first setting under "Configuration -> Path" ("Whole Path" or something like that) has to point to the real directory containing the s9y-files. "Relative HTTP-Path" has to point to the URL used for the Blog, be it / or /serendipity.

Ian is right in one regard: You should try to fix it better sooner than later, what you describe is somewhat fragile.
mintaka
Posts: 2
Joined: Wed Jul 31, 2013 8:41 pm

Re: Template lost when changing path or permalink: workaroun

Post by mintaka »

Thanks people, yes I see that the .htaccess redirects are overwritten when I change something, with the old "wrong" lines. I'll probably do a fresh install if there's no fix for this yet.

@Timbalu: "barking the wrong tree" is right somehow, I just don't have the time and will right now to make extensive tests and dig into the s9y core code. Maybe someday. It feels a little like windows: if it's broke - and it will slowly break for sure - do a fresh install.

@onli: The paths are correct. Only it seems that s9y doesn't handle the "index.php?[path]" calls correctly (I would rather live without those rewrites for simplicity but I understand that this adds another layer of code for flexibility and/or security).
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Template lost when changing path or permalink: workaroun

Post by Timbalu »

It says clearly: "...barking the wrong tree, changing the Serendipity root htaccess file"
which indicates, that these Serendipity rules are the best as set automatically, and working best for all kind of different setups over all these years, and for a blog host running correctly set up. Hopping between different directory setups will lead to errors, between host and directory setup.

You had a test blog in serendipity/ first and wanted to change this to a root / blog, trying to workaround this issue by changing your virtual host and the htaccess, in the way you did, as far as I understood this issue.
This will bring you into other and more strange situations. That is why I recommended, to set up your host correct and then install a fresh Serendipity blog, while this possibly is the cleaner and quicker way. This is far away to a comparison to MS-Windows! :wink:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply