I am trying to cleanup my rewrite rules a little bit, and I would like to understand them at the same time. And I have a few doubts...
a) What is the purpose of final rewrite
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]
? It throws /every/thing/what/ends/with.html - unmodified - at index.php. Therefore those carefully tuned rules for /archives, and the rule for index.html, could be just omitted as they achieve the same....
b) What is the purpose of rewriting /htmlarea to /htmlarea ?
c) Why some rewrites use
index.php?/<url-here>
while others
index.php?url=<url-here>
Are those fully equivalent (seems so)?
d) Why unsubscribe is rewritten to url=/unsubscribe/... while
approve, delete and admin to url=approve/... and so on (no leading slash)?
e) Some rules are labeled with [NC] (non-case sensitive), some are not. Why?
f) Am I right thinking that - while having the default permalinks structure - I'd achieve equivalent result via simple
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,QSA]
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
(= replace title part with -article suffix in entries links, apart from that pass everything to index.php)
?
g) Is it possible to make it more strict? Does there exist some documentation about which urls is serendipity generating?
Serendipity rewrite rules - what are some of them for?
Minor addition:
h) There is one more redundancy. We have two carefully tuned /feeds rules, then a rule which throw any /feeds at index.php:
RewriteRule ^(feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
# ....
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
h) There is one more redundancy. We have two carefully tuned /feeds rules, then a rule which throw any /feeds at index.php:
RewriteRule ^(feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
# ....
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Serendipity rewrite rules - what are some of them for?
Hi!
a) This is a rewrite rules that can redirect any .html link to serendipity, allowing plugins to take any permalink they want.
It's actually a fallback routine. Having other rules in there makes it easier to read and understand the s9y permalink architecture.
b) Phew. You got me on that. I believe this is a left-over from older times. I would need to browse through the SVN history to see when this rule might have gotten changed. But as it stands right now, I think it serves no purpose at all.
c) The "url" parameter was added later on only, to make it easier to access this as a $_REQUEST PHP variable. It was not adapted for older rewrite rules, cause they "worked alright" and nobody wanted to break the working system by changing variables here.
d) I believe this is a copy+paste error. I think it should be possible to unify those so that they all use a "/" prefix.
e) We only put [NC] on input that could come from a user, whereas those not using [NC] are usually s9y internal links that a user would not manually link himself. This is more a human choice on where we thought, case-insensitivity could be helpful.
f) Hm, I'm not sure. Some rules like comment rules or plugin patterns change the directory paths by shifting arguments...I don't know the imposed side-effects.
g) This might really harm the backwards-compatibility of URLs created by older serendipity versions. Since BC is kind of important to me, and I wouldn't like anyone's URLs to be not accessible anymore that people linked to from foreign pages, making the rules more strict might have really huge impacts.
The places that s9y emits permalinks should all be routed thorugh the serendipity_*url() functions declared in include/functions_permalinks.inc.php.
h) Some rules are quite "large" in the .htaccess because they share the same PHP constant that s9y uses internally to match up the permalinks.
Regards,
Garvin
a) This is a rewrite rules that can redirect any .html link to serendipity, allowing plugins to take any permalink they want.
It's actually a fallback routine. Having other rules in there makes it easier to read and understand the s9y permalink architecture.
b) Phew. You got me on that. I believe this is a left-over from older times. I would need to browse through the SVN history to see when this rule might have gotten changed. But as it stands right now, I think it serves no purpose at all.
c) The "url" parameter was added later on only, to make it easier to access this as a $_REQUEST PHP variable. It was not adapted for older rewrite rules, cause they "worked alright" and nobody wanted to break the working system by changing variables here.
d) I believe this is a copy+paste error. I think it should be possible to unify those so that they all use a "/" prefix.
e) We only put [NC] on input that could come from a user, whereas those not using [NC] are usually s9y internal links that a user would not manually link himself. This is more a human choice on where we thought, case-insensitivity could be helpful.
f) Hm, I'm not sure. Some rules like comment rules or plugin patterns change the directory paths by shifting arguments...I don't know the imposed side-effects.
g) This might really harm the backwards-compatibility of URLs created by older serendipity versions. Since BC is kind of important to me, and I wouldn't like anyone's URLs to be not accessible anymore that people linked to from foreign pages, making the rules more strict might have really huge impacts.
The places that s9y emits permalinks should all be routed thorugh the serendipity_*url() functions declared in include/functions_permalinks.inc.php.
h) Some rules are quite "large" in the .htaccess because they share the same PHP constant that s9y uses internally to match up the permalinks.
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/
# 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/