Hot answers tagged

36

UPDATE The answer to the main question is: JFactory::getUri() is deprecated, use JUri directly like this: <?php $uri = JUri::getInstance(); echo $uri->toString(); // or simpler: echo JUri::getInstance(); ?> The Strict Standards error is because of the & before JFactory::getURI();. You can find more information about that below. ORIGINAL ...


16

You can do that by enabling the SEF URLs and especially the parameter "Use URL rewriting" in the Joomla global configuration. Please note that this will generate an internal server error if you didn't create the .htaccess file before enabling the option. There is a doc page explaining what steps are needed to get those nice URLs. Have a look here: http://...


14

TOC of this answer: Content under same Item Id How Duplicate content is created / Dynamic Pages / URLs SEO perspective Dealing with Duplicate content in Joomla References and links 1. Why the Articles are being displayed under the same itemid First of all, this is not the problem why you are getting duplicate urls. The articles are using ...


13

Use JRoute for this: rtrim(JUri::base(), '/') . JRoute::_(ContentHelperRoute::getArticleRoute( $article->id, $article->catid )) but you don't need JUri::base() if you don't want to link to a different domain.


11

Step 1 Edit “components/com_content/router.php“, then continue on step 2. (You’ll probably have to re-do this step every time you update Joomla.) Step 2 (There are two places need to do this change, one near the top, one in the middle) Replace this: $advanced = $params->get('sef_advanced_link', 0); With this: $advanced = $params->get('...


6

According to the Joomla tutorial, you can get the current URL by this function: JUri::current();


6

With the below .htaccess rule you can redirect all pages from a url with the pattern of: https://www.portal-gestao.com/whatever/whatever/9999-title-of-the-page to a new url of : https://www.portal-gestao.com/item/9999-title-of-the-page htaccess: RewriteEngine On RewriteCond %{HTTP_HOST} ^www.portal-gestao.com RewriteRule ^.*/.*/(.*)$ https://www....


5

For anyone that don't want to get dirty with editing Joomla code, we shall mention that 3rd party SEF extensions provide the ability to remove the ids from the SEF urls. There are plenty of SEF extensions someone can find in JED: For example SH404SEF, is one of the most popular and used Joomla extensions, with long history and extended support by many 3rd ...


4

JFactory::getURI(); is deprecated. The correct method to get the current URL is: $uri = JUri::getInstance(); echo $uri->toString();


4

No, this is how Joomla's sef system works. If you were to make a menu item to an article, that too would lose its item id from the url. I think your only option would either be to override the router or use a sef plugin like sh404sef or Mijosef. The only other thing I can think of is to actually make the category menu item alias 9-cat1 but obviously if ...


4

There is a system plugin called System: SEF. When enabled, this plugin scans the final HTML output just before it is sent to the browser, and replaces any non-SEF links with their SEF counterparts by running it through JRoute::_($url);. This only works for internal links though beginning with index.php, so it won't work if the link starts with http://. Try ...


4

There is no easy way to override that. In the end it uses JFilterOutput::stringURLUnicodeSlug() or JFilterOutput::stringURLSafe() (depending on the global setting) to make the alias URL safe. Since & isn't a valid character in an URL it is stripped and replaced with a -. So you had to override a core class, which isn't recommended at all. The easier ...


4

You could add this code to the top of Joomla's index.php: if(strcmp($_SERVER['REQUEST_URI'], '/index.php') == 0 && $_SERVER['QUERY_STRING'] == ''){ header("HTTP/1.1 301 Moved Permanently"); header('Location: /'); exit; } Be careful though, if you take this approach, you'll need to redo this when you upgrade.


4

Changed htaccess.txt to .htaccess Site > Global Configuration : Use URL rewriting (Choose Yes) SEO Settings Search Engine Friendly URLs(Choose Yes)


4

There is no need to set non-friendly SEF URLs. I have a multilingual website too and I had your same problem. Do as following: Go to Plugins -> Language Filter and set Yes to: Remove the prefix from default language. Hope it helps :)


4

Instead of $_SERVER['REQUEST_URI'], you can rely on JUri::root() template parameter can not be added concatenating it with &. It has to be ? ... but it depends on the Url query. Thus, you need a piece of code like this to define the glue: $uri = JUri::getInstance($url); $query = $uri->getQuery(); if (empty($query)) { $glue = '?'; } else { $...


4

In AdminTools set "Enable Link Migration" to Yes and then enter the old host name ie. example.com (don't include http:// at the front) However this will not solve your problem. The fastest way is to export the SQL database and to replace every instance of http://example.com with http://archive.example.com and then reload the database. It only takes a few ...


4

There is a nice free plugin Language Domains from Yireo, which allows you to switch the domain-name as soon as a specific language is selected. Each domain is bound to a language, by configuring the plugin parameters. Once enabled, the plugin detects the current domain name, checks the current language, and redirects to a new domain if needed. You ...


4

The issue was down to a problem with a PDO database file MySQL driver, which is why it wasn't replicated on my other 3.5.0 site, which was using MySql. There is a fix here, or it should be patched in the next update: https://github.com/joomla/joomla-cms/pull/9610


3

This issue is caused by blank src attributes of a few tags: * <script src=""> * <iframe src=""> * <link href=""> * <img src=""> Whenever any media/page is referred with a blank source, it requests the current URL. Imagine that you have <img src=""> on the page at http://www.example.com/. The big problem is that each instance ...


3

Here is another way of getting the correct root URL of the site. This also takes care if your site is in subfolder $rootURL = rtrim(JURI::base(),'/'); $subpathURL = JURI::base(true); if(!empty($subpathURL) && ($subpathURL != '/')) { $rootURL = substr($rootURL, 0, -1 * strlen($subpathURL)); } Then you can do $url ...


3

In libraries/legacy/controller/legacy.php we changed: throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_NOT_FOUND', $name, $type, $prefix), 500); to throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_NOT_FOUND', $name, $type, $prefix), 404);


3

The simplest way to achieve the URL structure you mention is to create a Category called "News" and create your news articles in this category. This will give you a structure like: www.example.com/news/news1 www.example.com/news/news2 www.example.com/news/news3 Creating a sub-category under news could further refine this if needed: www.example.com/...


3

You could write a template override for the login template being called when the standard login url is displayed. There you create a HTTP 302 Move response status. Or you write a url rewrite to your .htaccess. Both solutions could get you where you wanna be, but I would consider them 'dirty'.


3

That's a bit strange, I guess it should be related to how you have linked the pdf. From where you link the pdf? In any case a direct hard-coded link to the pdf file like: images/sample.pdf should work. If this is how you have linked it, then you should give more details about your configuration, but also consider to check if you have any special ...


3

This post highlights a common problem with Joomla and other CMSes. Without the correct setup many different URLs can be indexed for the same page. Joomla applies an ID for each category and each item. For auto-generated links, all Joomla processes are these IDs (ie. /236-category-name/121-article-name) - the additional category names and article names are ...


3

What you could do is use Joomla's Redirect Manager to redirect the old URL to the new one. In the Joomla backend, go to: Components >> Redirect >> New In the Source URL field, enter the old URL and in the Destination URL field, enter the new URL


3

You can use JOOMSEF component, which is for SEO purpose and more of this extension is free. Also in that component you have option to remove category and menu names from url and also you can customize the url according to you.


3

It is not recommended to play with core files. It can have side-effects (where you are alone to support them) and you will have to patch them with every update. To customize Urls, it is highly recommended to install any SEF-oriented extension from JED/ Site Management/ Sef.


3

Make sure the System - SEF plugin is published. This plugin contains the following code, which should be adding the correct URL path to images before the page is rendered: // Replace src links. $base = JUri::base(true) . '/'; $buffer = $this->app->getBody(); // Replace index.php URI by SEF URI. if (strpos($buffer, 'href="index.php?') !== false) { ...


Only top voted, non community-wiki answers of a minimum length are eligible