Remove the category ID from the url
-
- Phoca Newbie
- Posts: 3
- Joined: 28 May 2015, 13:17
Remove the category ID from the url
Dear developer! First of all thank you for this lovely gallery.
Very hope for your help.
Tell me, please, how can I remove the category ID from the url.
It is very necessary for SEO, because, for example, category:
/gallery/category/1-plants
also available at:
/gallery/category/1-plant
/gallery/category/1-plan
/gallery/category/1-pla
and so on, because she has a numeric identificator. I need to such pages as:
/gallery/category/1-plant
/gallery/category/1-plan
/gallery/category/1-pla
would have given a 404 error, and I think it will turn out, if I can remove the category ID: /gallery/category/plants
I think I need to edit the file \www\components\com_phocagallery\router.php, but my knowledge is not enough.
I think the solution would be very useful for many other users.
Many thanks in advance.
P.S. Please, sorry for my bad English.
Very hope for your help.
Tell me, please, how can I remove the category ID from the url.
It is very necessary for SEO, because, for example, category:
/gallery/category/1-plants
also available at:
/gallery/category/1-plant
/gallery/category/1-plan
/gallery/category/1-pla
and so on, because she has a numeric identificator. I need to such pages as:
/gallery/category/1-plant
/gallery/category/1-plan
/gallery/category/1-pla
would have given a 404 error, and I think it will turn out, if I can remove the category ID: /gallery/category/plants
I think I need to edit the file \www\components\com_phocagallery\router.php, but my knowledge is not enough.
I think the solution would be very useful for many other users.
Many thanks in advance.
P.S. Please, sorry for my bad English.
- Jan
- Phoca Hero
- Posts: 47883
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Remove the category ID from the url
Hi, I think, this is a Joomla! forum question as the SEF (routes, URLs, ...) are made by Joomla! router methods (JRouter).
Anyway the numbers in urls are good for search outcomes, when the alias is changed, the link is still accessible thank to the number.
Jan
Anyway the numbers in urls are good for search outcomes, when the alias is changed, the link is still accessible thank to the number.
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 3
- Joined: 28 May 2015, 13:17
Re: Remove the category ID from the url
Hello, Jan!
Thanks for your answer!
Yes, in that sense, I agree with You.
But I'd rather get rid of the numbers in the url, and in the event of a change of alias would prescribe redirect in htaccess or by using the appropriate plugin.
I assure You that otherwise, over time, in the Google search will be a large number of duplicates, that eventually will lead to pessimization of the site.
I managed to get rid of the numbers in the url in the categories and articles in Joomla using instructions that I found on the Internet. Just a small edit two lines in the rooter.php file and the problem is solved.
But, unfortunately, it didn't work on gallery categories, as it has its own router...
Thanks for your answer!
Yes, in that sense, I agree with You.
But I'd rather get rid of the numbers in the url, and in the event of a change of alias would prescribe redirect in htaccess or by using the appropriate plugin.
I assure You that otherwise, over time, in the Google search will be a large number of duplicates, that eventually will lead to pessimization of the site.
I managed to get rid of the numbers in the url in the categories and articles in Joomla using instructions that I found on the Internet. Just a small edit two lines in the rooter.php file and the problem is solved.
But, unfortunately, it didn't work on gallery categories, as it has its own router...
- Jan
- Phoca Hero
- Posts: 47883
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Remove the category ID from the url
Hi, yes, such you need to customize in the router - somehow detect the ID and parse it somehow with the alias. I didn't do such customization yet, but I think it can work this way:
- instead of IDs you will use only aliases
- when alias is comming - you need to detect it in the database and change to ID - load the items from database by the ID then.
Jan
- instead of IDs you will use only aliases
- when alias is comming - you need to detect it in the database and change to ID - load the items from database by the ID then.
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 3
- Joined: 28 May 2015, 13:17
Re: Remove the category ID from the url
Hi Jan!
Thank You for the reply! Unfortunately, I can't do such adjustments.
If You don't mind, I'll write here changes that remove the ID from categories and news in Joomla 2.5 - Joomla 3.x.
Maybe someone wants to do such and in the Phoca Gallery, and it proves useful in solving the problem.
I would be very grateful if someone will succeed and he will share the solution in this topic.
Editing file: site.com/components/com_content/router.php
1. Line (twice):
Replace with (twice):
2. Find this pice of code:
And comment him:
That's all.
In any case, thank You very much.
Thank You for the reply! Unfortunately, I can't do such adjustments.
If You don't mind, I'll write here changes that remove the ID from categories and news in Joomla 2.5 - Joomla 3.x.
Maybe someone wants to do such and in the Phoca Gallery, and it proves useful in solving the problem.
I would be very grateful if someone will succeed and he will share the solution in this topic.
Editing file: site.com/components/com_content/router.php
1. Line (twice):
Code: Select all
$advanced = $params->get('sef_advanced_link', 0);
Code: Select all
$advanced = $params->get('sef_advanced_link', 1);
Code: Select all
if (strpos($segments[0], ':') === false)
{
$vars['view'] = 'article';
$vars['id'] = (int) $segments[0];
return $vars;
}
Code: Select all
/*if (strpos($segments[0], ':') === false)
{
$vars['view'] = 'article';
$vars['id'] = (int) $segments[0];
return $vars;
}*/
In any case, thank You very much.
- Jan
- Phoca Hero
- Posts: 47883
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Remove the category ID from the url
Hi, thank you for the guide.
Jan
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 7
- Joined: 04 Jun 2012, 21:40
Re: Remove the category ID from the url
It's quite old, but I see, nothing changes to the router displaying from few years (since I stop using phoca in 2014 :) ).
I try to read router.php and actualy I was wondering why function return $segments , when it is calculated once again in . Doesn't it make doubled $segments or something?
So I just commented at the and of and I noticed that link in browser changes from
I don't know for sure is that correct, but it did the trick. (of course both /galeria and /galeria/jesień-zima-monika are menu items)
Best regards.
it's not so simple, was working until I added more categories :) . So back to the beginning...
I try to read router.php and actualy I was wondering why function
Code: Select all
function PhocaGalleryBuildRoute(&$query)
Code: Select all
function PhocaGalleryParseRoute($segments)
So I just commented
Code: Select all
return $segments;
Code: Select all
function PhocaGalleryBuildRoute(&$query)
to/galeria/jesień-zima-monika/category/2-monika
./galeria/jesień-zima-monika
I don't know for sure is that correct, but it did the trick. (of course both /galeria and /galeria/jesień-zima-monika are menu items)
Best regards.
it's not so simple, was working until I added more categories :) . So back to the beginning...
- Jan
- Phoca Hero
- Posts: 47883
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Remove the category ID from the url
Hi, there were a lot of changes in router (mostly regarding more menu links, etc.)
There is new router planned in Joomla! so first we need to wait for Joomla! new feature and then such can be implemented (if possible)
But try to seem some SEO guides, displaying the number in URL has mostly more positive implicaciones than negative (great for stablie and long term URLs. In case of different changes, always the same content will be displayed as it is based on number).
Jan
There is new router planned in Joomla! so first we need to wait for Joomla! new feature and then such can be implemented (if possible)
But try to seem some SEO guides, displaying the number in URL has mostly more positive implicaciones than negative (great for stablie and long term URLs. In case of different changes, always the same content will be displayed as it is based on number).
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 3
- Joined: 21 Jan 2012, 11:55
Re: Remove the category ID from the url
Any plans about hidding /category/catid- in browser url?
Joomla today has the ability (by htaccess) to remove the category/id but it does not affect the gallery. Or perhabs Im just unknown?
Joomla today has the ability (by htaccess) to remove the category/id but it does not affect the gallery. Or perhabs Im just unknown?
-
- Phoca Hero
- Posts: 2734
- Joined: 28 Nov 2010, 17:20
Re: Remove the category ID from the url
Hi,
Kind regards, Christine
History behind: https://developer.joomla.org/news/674-s ... 3-7-0.html
Plan for Joomla 3.8 > https://www.smartaddons.com/blog/plan-f ... 38-release. Includes also link: discussion new router.jacoline wrote:Any plans about hidding /category/catid- in browser url?
Kind regards, Christine