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!
Redirect categories to tags with mod_rewrite
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Redirect categories to tags with mod_rewrite
Hi!
I think you need to escape your rewrite Rules differently, like
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
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]
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/
# 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/
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:
But still no go...
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
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
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
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
# 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/
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Did you raise the RewriteLogLevel to investigate?
Regards,
Garvin
Did you raise the RewriteLogLevel to investigate?
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/
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-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
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
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
# 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/
Solved
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:
Thanks for helping!
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^/categories/1-Example-Category$
RewriteRule ^index\.php?$ index.php?/plugin/freetag/Exampletag [R=301,L]