0

I would like to know how to add a trailing slash to joomla categories, but have no extension on articles.

Example, i want- xxx.com/category1/ and xxx.com/category1/article

Currently google sees- xxx.com/category1/ and xxx.com/category1 as duplicate content.

Kalana
  • 5,631
  • 7
  • 30
  • 51
Joel smith
  • 11
  • 5

1 Answers1

0

I would say you probably want to keep the URL without the trailing slash rather than the other way around. This just keeps it cleaner in the event that you have a category page which later needs a query string on the end of it. For example /categroy1?page=2 reads better than /categroy1/?page=2. This is personal preference though, Google does not really care so long as it's consistent.

The easy way to achieve what you are trying to do is through the .htaccess file in the root of your website.

Seems to be a few threads online about this subject. I've just tried a few of the solutions myself and the one that seems to work best is listed here https://forum.joomla.org/viewtopic.php?t=701030.

In summary you need to add the following to your .htaccess file just below the 'RewriteEngine On' statement.

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !administrator
RewriteCond %{REQUEST_URI} !component
RewriteRule ^(.*)/$ $1 [R=301,L]

Note that the Rewrite Base is needed, but if you are running your site in a sub folder (as you might in dev) you need to include that folder in the RewriteBase.

Apparently the !administrator and !component statements are needed to prevent some infinite loops when viewing the admin area, or a component content page without a SEF URL. There may be other exclusions that are needed.

Other options to solve your problem include canonical tags on the pages to tell the search engines which one you want indexed. Extensions to perform the redirect for you. Or if you have a really small site, use Joomla!'s redirect component to redirect every page you don't want to the one you do.

Hope this helps. KevBallard

  • Hey Kev, if you are able to provide Joomla support, please join us at [joomla.se] Stack Exchange and see if you can lend a hand resolving questions. Cheers. – mickmackusa Oct 07 '19 at 07:40