I realize this seems confusing, but let me give some background first ...
I have a node (say node/123
) with a path alias (call it: /books
). So if I go to http://example.com/books I'm viewing a page that's already been aliased by Drupal from /node/123
.
However, now I put a Views block on that page and that block has an exposed filter. So, when I filter results I end up with an URL that looks something like so: http://example.com/books?type=fiction
Now here's the problem: I want to rewrite the above URL into something like http://example.com/fiction-books
This isn't as easy as it seems:
- You can't use the pathauto module to set a new alias.
- You can't use a function like
hook_url_inbound_alter
or evencustom_url_rewrite_outbound
because the querystring doesn't exist in any of those.
I attempted a rewrite in htaccess, which seems like the best solution, but I can't get anything there to work (I suspect this is because of Drupal rewriting the alias already so the pattern to use there is confusing).
For the record I know almost nothing about rewrites, but I've got this in htaccess which doesn't work:
RewriteCond %{REQUEST_URI}^/books$
RewriteCond %{QUERY_STRING}^type=fiction$
RewriteRule %{REQUEST_URI}^/fiction-books$ [L,R=301]
So, how do I do it? Advice on an internal Drupal-way would be ideal. But if not, then help via an htaccess RewriteRule would be really appreciated.