What I'd like to do is that I want to make nice URLs for my roundcube pages with .htaccess.

For example:

RewriteRule    ^latest/$    index.php?_action=news&type=latest  [NC,L]

If I go to this page, the rewrite happens, so my latest new shows, but all the other resources broken.

This is because all of them coded as relative URLs. Unfortunately I have no influence to rewrite them to absolute urls, because roundcube template engine handle the output from the core, or from plugins.

I am a programmer, not a sysadmin, so I have only basic knowledge about rewrite rules.

Can you help me with this guys?

EDIT: This is what I've figure out, but for some reason it not works:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule    ^latest/$    index.php?_action=news&type=latest  [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRUle ^(.*?)\/(.*)$ https://%{SERVER_NAME}%/$2 [NC,L,R=301]

So my idea is that if not directory found, apply it to my directory, this works.

The seconf is if no file like that, remove the first directory, and redirect that file to the root. For some reason it not works.


EDIT2: Wow, it works, this is the good solution:

RewriteRUle ^(.*?)\/(.*)$ https://%{SERVER_NAME}/$2 [NC,L,R=301]

No need % sign (typo) after server name. I hope there are no side effects.

enter image description here

  • 1
    If you change the URLs, you also need to change the links to those URLs. Have you modified RoundCube to link to your new clean URL? – Stephen Ostermiller Oct 21 at 9:50
  • Nope, I did not change anything. What should I change? I know htaccess more or less, what I'd like to achive is that I should not change anything. Ok, dreaming is a good thing, but I think, maybe there is an option to force roundcube (from htaccess) to resolve these somehow to the base url. Do you think, is there a solution? – vaso123 Oct 21 at 12:39
  • I doubt that this can be done with just .htaccess. I don't know of a way of doing this without adjusting the setting on your CMS or editing its code. I don't know RoundCube at all, so I can't really help with it, but maybe somebody else here knows it better. – Stephen Ostermiller Oct 21 at 12:57
  • Do you need the slash suffix at the end of the "nice" URL? Where exactly are these nice URLs being used? Are you simply linking to these from an external page, or are you wanting to change the URLs throughout the RoundCube app? – MrWhite Oct 21 at 16:02
  • @MrWhite I have several categories for news, like tech, latest, etc... Now I am using this ?_action=news&type=tech for this. I'd like to turn it to '/tech/'. These are only on the pages where user has not logged in. Thats all, my above example works, but every other resources broken. – vaso123 Oct 24 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.