Skip to main content

Tweaking the SEF url's

How to get rid of the '2-', 'q-' and 't-' in the SEF urls?

short answer

you can't

long answer

the url contains vital information to display the correct items from your database. The keywords in the url must match the location of the keyword in the database. Therefore you can't simply remove the numbers in the url. Same goes for the title parameter ( 't-'), it indicates that the query is on the title and not a category, and the 'q-' indicating a com_datafeeds search.

There are options to remove some of the unwanted parameters, however there is no generic solution. Below is a brief  description on how to customize the template.

Removing the t-

In the module and component templates you will find the code used to generate the url to a product (title), example:

$product_url=JRoute::_( $this->where['baselink']."&". make_urlencoded(array("qt"=>$item['title'])));

(not all templates have a product link, and the code might differ look for the qt)

Create a new template and create your own url to replace to old one:

$product_url="/Product/".urlencode($item['title']);

Now add a rule to your .htaccess

RewriteRule /?Product/(.*) index.php?option=com_datafeeds&view=items&Itemid=2&qt=$1&q1= [QSA]

where the '2' must be changed to the correct menu item id and the empty q1 is to fool the joomla router

Tweaking other fields

The same can be achieved for single fields, for example a list of 'Brands' on a fashion site, url :

"/Merk/'.urlencode($item['Select9'])

in the menu configuration the field Select9 is mapped to the menu level 6, so the rewrite rule becomes:

Rewriterule /?Merk/(.*) index.php?option=com_datafeeds&view=items&Itemid=4&q6=$1&q1= [QSA]

 

Removing the q-

you can't with modifying core code

Removing the numeric id

you can't

The URI of a com_datafeeds menu defines the input for the database query. Each position in the URI maps to a field defined in the menu configuration. If the path is complete there will be no numbers:

https://www.badmode.co/online/Heren/Zwembroeken/Diesel.html

If the URI contains gaps the numbers are needed to map correctly, in the example mapping the keyword 'Adidas' to the menu level 3:

https://www.badmode.co/online/3-Adidas.html

to avoid the numbers:

  1. do not use the module template 'search', 'ajax' and similar pull-down menu's
  2. when using the default menu module template  ( and similar ) set levels to 1, this suppresses direct links to deeper menu levels.

Whenever a keyword contains a dash, the numeric value is added as well, due to joomla core behaviour.