The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue May 17, 2011 9:01 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
Hi

I have discovered a messy (for me) feature of Joomla 1.6.
Articles that is not tied to a menuitem cause Category links to be produced both in the URL and in the Breadcrumbs. This both produce (for me) ugly and counter-intuitive Breadcrumbs, as well as make it possible for the visitor to view pages that I do not want them to see.

I know how I can get rid of the Category links in the Breadcrumbs by hacking two core files, but I have no idea on how I direct an URL consisting of one or more categories, to the Error page (404).

You can test the "messy" behaviour by following the instructions below:

Now if you visit this URL:
http://monsanto.no/index.php/en/environ ... o/gmo-news
(which is the URL you get if you click the menuitem titled "GMO
news"

Then click the article titled:
"Why genetically modified organisms (GMO) should be prohibited"
(top-left in the category blog page)
Then you get to this URL:
http://monsanto.no/index.php/en/environ ... prohibited

Now you will see "Related articles", below the menu to the right.

Now click the article in Related articles" titled "The Future Of
Food".
(this is one of the articles that is only linked to the category "GMO
videos". It is not tied to any of
the menuitems in any way).
Then you get to this URL:
http://monsanto.no/index.php/en/environ ... re-of-food

And the Breadcrumbs now consist of these parts:
Home Environment GMO "GMO news" English Environment "GMO
(Genetically Modfied Organism)" "GMO videos" "The Future
Of Food"

You also see that the URL consist of different categories in addition to the menu-path.
The categories parts are:
101-english/environment/gmo-genetically-modfied-organism/gmo-videos

Now try click any of the Category links in the Breadcrumbs which is one of the following:
English Environment "GMO (Genetically Modfied Organism)" GMO videos

Clicking any of these links will show pages I do not want to be accessible.
And these Category links will also be indexed by search-engines.
***************************************

For me, the behaviour, as demonstrated above, result that I loose control over what the visitor see. I only want the visitor to access pages that I make access to via the site MENU.

I can get rid of the Category links in the breadcrumbs by changing these two core files:

/components/com_content/views/article/view.html.php

Comment out this code (approx line 197):
Code:
$category = JCategories::getInstance('Content')->get($this->item->catid);
         while ($category && ($menu->query['option'] != 'com_content' || $menu->query['view'] == 'article' || $id != $category->id) && $category->id > 1)
         {
            $path[] = array('title' => $category->title, 'link' => ContentHelperRoute::getCategoryRoute($category->id));
            $category = $category->getParent();
         }


And this file:
/components/com_content/views/article/view.html.php
Code around line 202 to 218 (not tested yet though).

But the problem is that search engines have allready indexed my "unwanted" category pages by indexing the Category links displayed in the Breadcrumbs. So even if I make the hacks above in order to remove the Category links in the Creadcrumbs, the Unwanted URL's floating on the www will still show the unwanted pages to the visitors

So I need to be able to (at least #1):

1.
I believe that if I can change the one place where Joomla produce article URL's, I could only make that one change (except for the breadcrumbs hacks above). But that change should affect the build of URL's for articles across the whole site (if possible). How / where do I make that change?


2.
Handle all URL's containing one or more categories.
These URL's should allways direct user to the Error (404) page.


Does anybody know what file(s) I have to change to make this work?
If example code (great), if not, the filename and function(s) will be great.


Last edited by bongobongo on Sat May 21, 2011 11:24 pm, edited 6 times in total.

Top
 Profile  
 
PostPosted: Tue May 17, 2011 9:09 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
If you want ALL pages with a certain number of folder levels in the URL to produce an error message for ALL visitors, you could add an internal rewrite in your .htaccess file to a mark those URLs as Gone (HTTP status 410). The rewrite would need to be added just before Joomla's core SEF rewrite code.

This code works for 3 folder levels on a URL with .html extension:
Code:
RewriteRule ^[^/]+/[^/]+/[^/]+/([^/.]+\.)+html$ - [G]

This code works for 3 folder levels on an extensionless URL:
Code:
RewriteRule ^[^/]+/[^/]+/[^/]+/[^/.]+$ - [G]

The pattern can be adjusted for more or for less levels and it could be duplicated and/or edited to include specific folder names.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Tue May 17, 2011 9:20 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
I do not understand how that could work.

In my cases above the first parts of the URL will consist menu parts, then the category parts are added. Using rewrite in .htaccess could not possibly know what is menu parts and what is category parts... Or am I wrong?

If URL only consist of menuparts, like this one:
http://www.monsanto.no/index.php/en/env ... o/gmo-news
then I do not want any redirect.

But if URL also consist of one or more category parts like this:
http://www.monsanto.no/index.php/en/env ... re-of-food

or like this:
http://www.monsanto.no/index.php/en/env ... 77-english
or:
http://www.monsanto.no/index.php/en/env ... nvironment
as well as countless of other examples
then I want error page 404 to cick in.


Top
 Profile  
 
PostPosted: Tue May 17, 2011 9:29 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
You would have to find a way to distinguish the different types of URL and alter the RegEx pattern to match only those you want Gone.

Is there a common feature in all the URLs to retain or in all the URLs to not retain?

Additionally, the index.php/ part of your URL is clutter that you should consider removing.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Tue May 17, 2011 9:34 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
I removed text.. could not delete post.


Top
 Profile  
 
PostPosted: Tue May 17, 2011 5:37 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
I have found that in order to get rid of the Category names in e.g. Article URL's produced by Related articles module I can comment out some code in the function getArticleRoute in:
/components/com_content/helpers/route.php
Code:
if ((int)$catid > 1)
      {
         $categories = JCategories::getInstance('Content');
         $category = $categories->get((int)$catid);
         if($category)
         {
            $needles['category'] = array_reverse($category->getPath());
            $needles['categories'] = $needles['category'];
            $link .= '&catid='.$catid;
         }
      }


But this causes

Article links in category blog pages gets broken and get URL like this:
Code:
http://www.monsanto.no/index.php/no/miljo/gmo/gmo-nyheter?id=98:den-norske-gmo-skandalen


Article links in search result look like this (work but look ugly):
Code:
http://www.monsanto.no/index.php/no/component/content/article?id=140:gmo-poison-on-the-platter


Article links in Related articles look like this (work but look ugly):
Code:
http://www.monsanto.no/index.php/no/component/content/article?id=127:the-future-of-food


How can I fix this?

I also see that when I create a link to an article within an article, using the "Article" button below the text-editor area (e.g. in TinyMCE), then I still get Category names in the article URL.
What do I have to fix that?


Top
 Profile  
 
PostPosted: Wed May 18, 2011 8:03 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
g1smd: You asked me this question:
Is there a common feature in all the URLs to retain or in all the URLs to not retain?

Yes, actually there is:

Example of non-wanted english URL:
Code:
http://monsanto.no/index.php/en/environment/gmo/gmo-news/101-english/environment/gmo-genetically-modfied-organism/gmo-videos/


Example of non-wanted Norwegian URL:
Code:
http://www.monsanto.no/index.php/no/miljo/gmo/gmo-videoer/102-norsk/miljo/gmo-genetisk-modifisert-organisme/gmo-videoer


All unwanted English URL's contain this part:
"101-english"

All unwanted Norwegian URL's contain this part:
"102-norsk"

Ideally I would like to handle this URL:
Code:
http://monsanto.no/index.php/en/environment/gmo/gmo-news/101-english/environment/gmo-genetically-modfied-organism/gmo-videos/

in the following way:

These parts are all Categories:
/101-english/environment/gmo-genetically-modfied-organism/gmo-videos/

URL containing:
"101-english", and then "/gmo-videos" at the end should be directed to:
http://monsanto.no/index.php/en/environ ... gmo-videos

URL containing:
"101-english", and NOT "/gmo-videos" at the end should be directed to:
http://monsanto.no/index.php/en/environ ... o/gmo-news

If the above is not possible then I would like to follow these rules:
URL containing:
"101-english" should be directed to:
http://monsanto.no/index.php/en/environ ... gmo-videos

It would also be nice if I could do this in such way that the search engines understand that the URL's entered or clicked by the visitor is not to be visited. But that is perhaps difficult unless I force a redirect to the error page (404) page. Is this correct?
Since I now have hacked Joomla so the Categories no longer end up in Breadcrumbs, and therefore no longer can be indexed, I also believe that the unwanted URL's wil dissappear over time, as the search engines reindex my site.


Top
 Profile  
 
PostPosted: Wed May 18, 2011 8:20 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
A redirect returns a 301 or a 302 response, so you never "redirect" to an error page.

For a "page not found" error you should return a 404 response in the HTTP header and then a human-readable error message in the HTML page. The URL shown in the browser address bar must NOT change.

Yes, you can have different rules for your various types of URLs. The pattern matching in the RewriteRule should be adjusted to match each one. You'll likely end up with several rules, with one for each type of URL.
Code:
# Requested URL contains string1 and string 2
RewriteCond %{REQUEST_URI} string2
RewriteRule ^([^/]+/)+string1/([^/]+/)+([^/.]+)+$ http://www.example.com/new-path [R=301,L]

# Requested URL contains string 1 but does not contain string2
RewriteCond %{REQUEST_URI} !string2
RewriteRule ^([^/]+/)+string1/([^/]+/)+([^/.]+)+$ http://www.example.com/new-path [R=301,L]

You will need the Live HTTP Headers extension for Firefox to properly test the HTTP responses sent from your server.

Make sure that "new URL" does not contain "string1" otherwise you will have an infinite redirect loop.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed May 18, 2011 8:29 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
g1smd:
Could you please show how htaccess rewrite code look like if I want to follow these rules:

UPDATE
Sorry... You have allready answered that: BIG THANKS!


Will 301 code make the search engines to update the "unwanted" URL to the "new" one?


Top
 Profile  
 
PostPosted: Wed May 18, 2011 8:44 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
The whole point of the 301 redirect is to say to users and searchengines alike...

"Heh, the stuff you asked for isn't here, it is now over there. Make a new request for this new URL if you still want it..."



By the way, this is how you force a "410 Gone" response (which is even better than "404 Not Found") for some URL:
Code:
RewriteRule ^some-path - [G]

_________________
Online since 1995.


Last edited by g1smd on Wed May 18, 2011 8:47 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed May 18, 2011 8:46 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
g1smd:

You said:
Code:
# Requested URL contains string1 and string 2
RewriteCond %{REQUEST_URI} string2
RewriteRule ^([^/]+/)+string1/([^/]+/)+([^/.]+)+$ http://www.example.com/new-path [R=301,L]


Is it possible to make the above work only if string1 is last part in the URL?


Top
 Profile  
 
PostPosted: Wed May 18, 2011 8:48 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
bongobongo wrote:
Is it possible to make the above work only if string1 is last part in the URL?

Yes, just delete the rest of the pattern up to, but not including, the $ symbol, like ^([^/]+/)+string1$ or similar.


The stuff between ^ and $ is a pattern using Regular Expressions. The ^ and $ have special meaning and are optional too. Read a good RegEx tutorial and you will see how powerful and useful this is.

You might also find the (this|that)/ structure useful as it matches "this/" OR "that/".

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed May 18, 2011 10:04 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
g1smd:
Thanks a lot for your help! :)


The only thing's that's left now is to find a way to
prevent joomla from producing article URL's with Category names in them.
If someone know how to make an override or a hack for that... please let me know.

(Just have a look at my original post in this thread to find out what that is all about)


Top
 Profile  
 
PostPosted: Thu May 19, 2011 6:47 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
I have now filed a feature request here:

http://joomlacode.org/gf/project/joomla ... m_id=25930


Top
 Profile  
 
PostPosted: Sat May 21, 2011 5:29 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
Articles not tied to any menuitem produce URL's with category names in them.
I do not want it to happen. It is an UGLY feature of Joomla, at least for those admins which only want the menu structure on the frontend to control which page should be accessible to the visitors.

Which file(s) and what code in that (those) files are responsible for producing the category names in the URL's for these articles?

Could somebody please share that information?


Top
 Profile  
 
PostPosted: Tue Sep 27, 2011 10:21 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
I thought I had found most of the bad URL's, which happens to float around on google, because of the way the breadcrubs (and perhaps the URL's) are created by Joomla 1.6/1.7 when an article is not linked to a specific menuitem.

Here is the latest UGLY landing page found on my site:
http://www.monsanto.no/index.php/en/env ... gmo-videos

Here is what GMO videos really should look like (when you click GMO videos in the menu):
http://www.monsanto.no/index.php/en/env ... gmo-videos

The above page would not be accessible from my site anymore, but it happens to exist on Google, because it was indexed before I created a hack which prevented category-links from showing in breadcrumbs.

I would really appreciate if someone could tell me how I prevent Joomla 1.7 NOT to include category alias in the URL. I need to hack some core files.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2011 9:20 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Sep 01, 2011 10:39 am
Posts: 16
Location: UK
I'm trying to do the same (remove category from URL). http://forum.joomla.org/viewtopic.php?f=544&t=663197
Not sure if this helps you but AceSEF can do this. http://extensions.joomla.org/extensions/site-management/sef/10019
It doesn't work for me because it relies on full article alias rather than ID as the default Joomla SEF does.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2011 10:52 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
aa121 wrote:
I'm trying to do the same (remove category from URL). http://forum.joomla.org/viewtopic.php?f=544&t=663197
Not sure if this helps you but AceSEF can do this. http://extensions.joomla.org/extensions/site-management/sef/10019
It doesn't work for me because it relies on full article alias rather than ID as the default Joomla SEF does.


Thanks for the reply:
The demo site for the AceSEF is not working. (A side note: Actually I do not mind if the article-id is showing in the URL's, as they do for me now. I want the article id in my URL. One reason for this is if I choose to change the title for the article ... and title alias... then my article will still show up when google searchers click my old URL. The only thing with the article id is that I would like to see it at the end of the URL, instead of in the beginning of the last part of the URL).

I'm quite surpriced that nobody here can tell me which files I need to change in order to remove the category aliases from my URL'. It should not be that much to change ... or??
So who can tell us that?


How nice it would be if a developer made it optional to show the category aliases, in the article URL, from joomla backend.
But... looks like no developer are interesting in this.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2011 7:09 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
You cannot fix this problem with redirects alone.

URLs are defined in links.

Once the link is clicked, it is "too late" to "change" the URL. If your site links to URLs within the site that redirect to somewhere else within the site, Google will flag your site as being of "low technical quality".

If you don't want the category in the URL then omit it from the links on the page.

You should install a redirect but the purpose of the redirect is only to alert searchengines to update their index and to redirect people following stale links from other sites and in their stored bookmarks.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Fri Oct 07, 2011 7:45 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
g1smd:

My issue here originally came from the fact that if I create an article and do not 'bind' it to a menuitem, either directly or indirectly (when using Category blog page), then Joomla will produce URL's (e.g. from within Related articles module) that consist of the category alias.
Note that in a site of mine, which I refer to here, these kind of articles also resulted in breadcrumbs which displayed Categories (with URL's).

I did not want those Breadcrumbs, with Categories in them, to show up. The reason for this is that spiders like Google will index these URL's. This again will make it possible for a visitor to land on a page which I never wanted to show to my visitors in the first place.

So in my case, I wanted to prevent Joomla to from producing the URL's pointing to a category.
I found out how to get rid of the Category (URL's) in the breadcrumbs... which I have posted here earlier.

What I have not managed to fix, is how to get rid of the Category parts in the URL's produced for these particular articles (the articles not tied to a menuitem or e.g. a Category blog page).

To see this in action you should visit these pages:

a) First an article which is tied to a menuitem or category blog:
First a link to a category blog page:
http://www.monsanto.no/index.php/en/env ... o/gmo-news

Now if you click on one of those articles there: E.g. this one:
http://www.monsanto.no/index.php/en/env ... s-in-india

Then the URL for the page above look like this:
Code:
http://www.monsanto.no/index.php/en/environment/gmo/gmo-news/117-gmo-bt-cotton-linked-to-livestock-deaths-in-india


And the breadcrumbs look like this:
Code:
Home  Environment  GMO  'GMO news'  'GMO Bt cotton linked to livestock deaths in India?'


Now if you click on an article from the Related articles in the right column (below the tags) which belong to an article which is not tied to a specific menuitem (note: not all articles are of this type though):

Click the article titled: "The Future of Food" ... which takes you here:
http://www.monsanto.no/index.php/en/env ... re-of-food

This URL look like this:
Code:
http://www.monsanto.no/index.php/en/environment/gmo/gmo-news/101-english/environment/gmo-genetically-modfied-organism/gmo-videos/124-the-future-of-food


The breadcrumbs look like this:
(But only because I have made a change in a core joomla file so the Category links in the breadcrumbs do not show.
Code:
Home  Environment  GMO  'GMO news'  'The Future Of Food'


If you look closely at the URL for the article: The Future of Food .... above then you see it consist of these parts:

http://www.monsanto.no/index.php/
en/
environment/
gmo/
gmo-news/

101-english/
environment/
gmo-genetically-modfied-organism/
gmo-videos/
124-the-future-of-food

THE parts from '101-english' and untill 'gmo-videos' are all category aliases.
This are the parts I do not want to show up in the URL for articles. No categories (aliases).

Earlier, before I made the changes to how breadcrumbs where produced, these category aliases would also show up in the breadcrumbs.... all with a link to a page which I did not want to be accessible for the visitor (or the Google spiders etc)...

The reason why I use redirects in my htacess file is only because I found that many of these unwanted URL's had been indexed by e.g. Google.

To give you an example of such an URL indexed by Google then it would be an URL like this:
Code:
http://www.monsanto.no/index.php/en/environment/gmo/gmo-news/101-english

Which takes you to this page:
http://www.monsanto.no/index.php/en/env ... 01-english

Which of course makes no sense at all, because now a norwegian article is displayed in
the english version of the site... Quite messy.
These kinds of URL's would be picked up by the previously generated Category links in the breadcrumbs (which I have removed).

Here is the real URL to the norwegain article by the way, which also show you why that particular URL take the visitor to an unrealistic page ... the article id of the norwegian article is the same as the category id from the english URL:
Code:
http://www.monsanto.no/index.php/no/miljo/gmo/gmo-nyheter/101-hvis-gmo-er-genetisk-forurensing-sa-er-terminator-fro-slutten-pa-livet


Note that the fishy URL example from above is just one of many. Not all show conflicts like the one above where an article from another language version of the site is displayed in a place where it should not. My main point is that I do not want my visitors to get access to these Category URL's at all. But the way Joomla is designed now, may produce URL's that leads the visitor to unwanted landing pages.

Here is a few more examples of unwanted landing URL's (which would appear in the breadcrumbs before I made some core changes to how breadcrumbs are produced, also note that the 4 fishy URL's described here (1 above) and 3 below all comes from the article: The Future of Food:
Code:
http://www.monsanto.no/index.php/en/environment/gmo/gmo-news/101-english/environment/gmo-genetically-modfied-organism/gmo-videos

http://www.monsanto.no/index.php/en/environment/gmo/gmo-news/101-english/environment/gmo-genetically-modfied-organism

http://www.monsanto.no/index.php/en/environment/gmo/gmo-news/101-english/environment


Now, If you or anybody else, know which file(s) I have to change to get rid of the category aliases in the URL's for articles in general, then that would be great :)


Top
 Profile  
 
PostPosted: Fri Oct 14, 2011 10:52 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
Is there really nobody who can answer this question?

Which files do I have to change so Category alias do not show up in article URL's?


Top
 Profile  
 
PostPosted: Fri Oct 21, 2011 8:43 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Oct 21, 2011 8:36 pm
Posts: 3
bongobongo wrote:
I know how I can get rid of the Category links in the Breadcrumbs by hacking two core files,


Could you share which two files you edited, and in what way you did so? After searching the interwebs this is where I have arrived. I'm familiar with editing lines in php, so no tutorial is needed in that area. Just the line number and correct code. Thanks and I hope you get your question answered about the extremely long urls that you're up against.


Top
 Profile  
 
PostPosted: Fri Oct 21, 2011 9:45 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
Yes I can:

in:
Code:
/components/com_content/views/article/view.html.php


Comment out these lines:

Code:
$category = JCategories::getInstance('Content')->get($this->item->catid);
         while ($category && ($menu->query['option'] != 'com_content' || $menu->query['view'] == 'article' || $id != $category->id) && $category->id > 1)
         {
            $path[] = array('title' => $category->title, 'link' => ContentHelperRoute::getCategoryRoute($category->id));
            $category = $category->getParent();
         }


If you find out how to remove category aliases in article URL's, then please post it in this thread!


Top
 Profile  
 
PostPosted: Sat Oct 22, 2011 1:16 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Oct 21, 2011 8:36 pm
Posts: 3
Worked wonderfully thanks again!!!


Top
 Profile  
 
PostPosted: Wed Oct 26, 2011 7:54 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Quote:
Actually I do not mind if the article-id is showing in the URL's, as they do for me now. I want the article ID in my URL. One reason for this is if I choose to change the title for the article ... and title alias... then my article will still show up when google searchers click my old URL. The only thing with the article ID is that I would like to see it at the end of the URL, instead of in the beginning of the last part of the URL

I prefer article ID in URL, followed by article title. The article ID is the unique reference for the article. I prefer the article ID at the beginning as it makes it much easier to set a redirect to the correct URL should the article name change or the article title wording within the link be accidentally truncated.

There's no good reason for including category names in URLs. For a site with multi-faceted navigation I consider it to be a fundamental design flaw. Unfortunately I don't know which files you need to edit in order to fix this issue.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed Oct 26, 2011 8:09 pm 
Joomla! Master
Joomla! Master

Joined: Mon Oct 27, 2008 9:27 pm
Posts: 13759
Location: Akershus, Norway
Mod. Note: Relocated the topic to the SEO forum.


Top
 Profile  
 
PostPosted: Thu Dec 22, 2011 11:07 am 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
NOTE!
If you follow my initial description (post in this thread) on how to produce the unwanted behaviour in Joomla... which are described below this line:
"You can test the "messy" behaviour by following the instructions below:"

then it is no longer possible to see the messy behaviour!
Since I did not get any feedback on how to fix this, I had to change the structure on the related website, in order to prevent those unwanted URL's (pointing to category pages which I never wanted to be visible by the visitors), beeing indexed by e.g. Google.

Anyway, if someone happens to know which files I have to change in joomla, in order to remove category names from the article URL's, then I'm still VERY interested in seeing which files and what code to change.


Top
 Profile  
 
PostPosted: Wed Jan 04, 2012 3:37 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Dec 24, 2011 10:54 am
Posts: 3
Quote:
Anyway, if someone happens to know which files I have to change in joomla, in order to remove category names from the article URL's, then I'm still VERY interested in seeing which files and what code to change.

I found the following solution after looking deeply inside Joomla code.
goto file:
Quote:
components\com_content\router.php

Somewhere near line 82, and insert the 4 lines below in between the comments
Code:
               $alias = $db->loadResult();
               $query['id'] = $query['id'].':'.$alias;
            }
            ///////insert the following 4 lines here!!  /////////
            $segments[] = $query['id'];
            unset($query['id']);
            unset($query['catid']);
            return $segments;
            //////////////////////////////////////////////////
         } else {
            // we should have these two set for this view.  If we don't, it is an error
            return $segments;
         }

Try it on a test server AT YOUR OWN RISK

Please let me know if this resolve your problem


Top
 Profile  
 
PostPosted: Thu Mar 29, 2012 5:54 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Sep 26, 2011 11:18 am
Posts: 14
I have a similar problem. A set of URLs formatted as follows: http://www.domainname.com/2-uncategoris ... rticleslug are being generated. I'm not linking to them yet Google found them and indexed them. I've cleaned that part up, but every article seems to have two urls: a "clean" one and one with the category name and article ID jammed into it.

bongo bongo stated this:
Quote:
Since I did not get any feedback on how to fix this, I had to change the structure on the related website, in order to prevent those unwanted URL's (pointing to category pages which I never wanted to be visible by the visitors), beeing indexed by e.g. Google.


I'd be interested in hearing how you restructured things to fix this.

Like the other posts, I'd be very interested in solving this through a hack or, really any method. It's pretty ugly.

thanks.


Top
 Profile  
 
PostPosted: Fri Mar 30, 2012 5:35 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Dec 15, 2008 11:10 am
Posts: 319
Hi YadaYada14

The original reason which resulted in this ugly behaviour, for me, was that articles which where not linked to a menuitem, produced breadcrumbs with category links in it, as well as categories in the URL.

When I created a menuitem as Category blog, and then linked the articles to the category used by the Category blog, ... then that solved it for me.

I still believe that it should be made possible in Joomla, to prevent links to categories to show up in the breadcrumbs, as well as in the URL... as an optional feature.

I used quite a few hours to clean up the mess this behaviour caused for me.
This is also something most admins know nothing about.
As a site admin, you would like to be in control over what content is displayed on your site... as Joomla works today... you might get a big surprice.

I also filed a feature request in hope for a solution. But it was closed.

If you are unable to fix your problem, then please post more information here... and I'll see If I can help...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2  Next



Who is online

Users browsing this forum: strumjan and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group