Page 1 of 1
Redirect categories to tags with mod_rewrite
Posted: Sat May 13, 2006 4:04 pm
by krist
I have recently removed all categories of my blog in favour of the tags plugin. I'm very happy with my new freedom and the ability to connect the articles by browsing the tags. It appeared that one category was quite popular and some people have bookmarked it or subscribed to its feed. These people now only get a page saying "No entries to print", reload 1-2 times and leave.
I thought I'll just put a few rewrite rules into .htaccess and everything will be fine, but unfortunately I can't get it to work. Why does something like
RewriteEngine On
RewriteBase /
RewriteRule ^index.php?/categories/1-Example-Category index.php?/plugin/freetag/Exampletag
not work? I still get the empty category overview. Rewriting should basically work on my system, if I enable mod_rewrite in the s9y config it works and other php-based pages work, too. What am I missing?
Thanks for any help!
Re: Redirect categories to tags with mod_rewrite
Posted: Sun May 14, 2006 2:45 pm
by garvinhicking
Hi!
I think you need to escape your rewrite Rules differently, like
Code: Select all
RewriteEngine On
RewriteBase /
RewriteRule ^index.php\?/categories/1\-Example\-Category index.php?/plugin/freetag/Exampletag [L,QSA]
What you could do instead is something along the lines of patching rss.php; you could just check what $_GET['category'] is set to, and then set $serendipity['GET']['tag'] to the appropriate tag. Don't know if that works, though.
Best regards,
Garvin
Posted: Mon May 15, 2006 10:39 am
by krist
Hi Garvin!
Thanks for your suggestion, unfortunately it doesn't work (escaping). I've enabled some rewrite logging and it seems that despite escaping the special characters only the requested file (index.php) is compared to the rewrite rule, not the whole url.
EDIT:
After some more googling I tried a conditional rewrite rule involving {REQUEST_URI} which should provide the actual requested uri:
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^index.php\?/categories/1-Example-Category [NC]
RewriteRule (.*) /index.php\?/plugin/freetag/Exampletag
But still no go...
Posted: Mon May 15, 2006 12:31 pm
by garvinhicking
Hi!
That REQUEST_URI thing was a good idea. Maybe you could now try to just capture the "/category/1-x/" part of it, without the index.php?
HTH,
Garvin
Posted: Tue May 16, 2006 4:42 pm
by krist
Does not work either... this is getting strange!
Posted: Tue May 16, 2006 4:47 pm
by garvinhicking
Hi!
Did you raise the RewriteLogLevel to investigate?
Regards,
Garvin
Posted: Wed May 17, 2006 10:23 pm
by krist
It still does only compare the requested file:
Code: Select all
(4) RewriteCond: input='/index.php' pattern='^index.php\?/categories/1-Example-Category' => not-matched
Posted: Thu May 18, 2006 10:04 am
by garvinhicking
Hi!
Maybe you can play with the [QSA] option? Maybe also asking on a apache/mod_rewrite specific forum might get some more help?
Regards,
Garvin
Solved
Posted: Sat May 20, 2006 1:25 pm
by krist
So after reading the
mod_rewrite docs with a little more patience and a hint from another forum I could come up with a working solution:
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^/categories/1-Example-Category$
RewriteRule ^index\.php?$ index.php?/plugin/freetag/Exampletag [R=301,L]
Thanks for helping!