I'm looking for some specific advise - I am removing Joomsef from one of my sites as the support is poor and I need to rewrite some specific url's generated by the widgetkit component as the core sef does not seem to target these.

Anyway, one of the url's previously generated by Joomsef is /residential-work/buckingham-street the url for this page without Joomsef is /residential-work?layout=edit&id=32

I have been fiddling around with the .htaccess for a couple of hours trying to get the correct rule to no affect - always a 404 on the /residential-work/buckingham-street url.

My latest attempt was:

RewriteRule ^/residential-work?layout=edit&id=32$ residential-work/buckingham-street [R=301,L]

But no joy, I have also tried adding the rule in different area's of the htaccess but am still unable to get the rule to work.

Once I have it working I need to replicate this across a number of url's so any help getting this working would be most appreciated.

Edit: I have just tried the following also and this does not work either:

RewriteCond %{QUERY_STRING} (^|&)layout=edit($|&)
RewriteCond %{QUERY_STRING} (^|&)id=32($|&)
RewriteRule ^residential-work$ /residential-work/buckingham-street?&%{QUERY_STRING}

So in summary, I want to rewrite /residential-work?layout=edit&id=32 so that it is residential-work/buckingham-street

Regards Donna

1 Answer 1


Does going directly to /residential-work/buckingham-street work or does it 404?

If it doesn't work by itself, redirect people there isn't going to work (you're redirecting people to a no-longer-existing location).

Joomla's SEF routing works like this:

When a visitor requests a URI like residential-work/buckingham-street Joomla looks up which menu item has residential-work as the menu alias (after checking whether or not there is a sub-menu of residential-work with the alias buckingham-street).

If found it checks which component type that menu item is (in this case, a widgetkit component).

It then loads that component's route.php file (/components/<component name>/route.php) and passes all the of URI data (/residential-work/buckingham-street) to a parse() method there. The parse() method translates /residential-work/buckingham-street into the query variables that widgetkit needs to fulfill the request (eg, it returns back that the "option" is "com_widgetkit" and the "layout" is "edit" and the "id" is "32", etc). Joomla then passes that information into the main widgetkit component file for processing.

widgetkit's route.php also has the rules for building the SEF URL (it's build() method) from the pieces.

So if the links you're getting from Joomla to that page are /residential-work?layout=edit&id=32 it means that widgetkit's route.php build() method doesn't have the right rules to convert /residential-work?layout=edit&id=32 into /residential-work/buckingham-street, and, if you're getting 404s when attempting to load /residential-work/buckingham-street it means widgetkit's route.php parse() method doesn't have the right rules to convert /residential-work/buckingham-street back to it's needed data values (layout=edit, id=32, etc).

I'd say you have few options:

1) Redirect all the old URLs the new ones (redirect /residential-work/buckingham-street to /residential-work?layout=edit&id=32, not the other way around). Joomla still wont use/understand those old URL but at least they wont 404.

2) Contact the widgetkit devs and ask them if they can update route.php to work the way you want.

  • Hi Drew - As per your last 2 steps, it obvisously isn't clearin my original post - I am trying to re-write the /residential-work?layout=edit&id=32 so that it is /residential-work/buckingham-street
    – Dtorr1981
    Oct 12, 2017 at 7:29
  • I understand that's what you're attempting, but if /residential-work/buckingham-street doesn't load now, it's not going to load using any htaccess technique other than a redirect to the correct URL (/residential-work?layout=edit&id=32). If you don't want that redirect to show in the address bar you can use the [P] flag (mod_proxy) but that has security risks and it's not going to change how Joomla itself makes links. That means you'll need to make redirects for every existing and every new page you make that you want an SEF URL for.
    – Drew G
    Oct 12, 2017 at 16:42
  • Hi Drew - I do not want a redirect I merely want to 'ReWrite' /residential-work?layout=edit&id=32 so that it displays as /residential-work/buckingham-street - The problem is that JoomSef created the /residential-work/buckingham-street url but now it is unistalled the URL displays as /residential-work?layout=edit&id=32. I want this URL to be converted into the SEF Url if that makes sense?
    – Dtorr1981
    Oct 14, 2017 at 11:56
  • Yes. What you want can only be achieved with option 2. In order for Joomla to do that the component's routing (route.php) needs to be changed. Give this a read: docs.joomla.org/J3.x:Supporting_SEF_URLs_in_your_component
    – Drew G
    Oct 14, 2017 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.