The Joomla! Forum ™






Post new topic Reply to topic  [ 26 posts ] 
Author Message
PostPosted: Sun Sep 06, 2009 11:26 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun May 18, 2008 10:18 am
Posts: 25
Location: Finland
Is it possible to have this "Add suffix to URLs" with .htm instead of .html


Top
 Profile  
 
PostPosted: Sun Sep 06, 2009 9:05 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Fri May 02, 2008 10:35 pm
Posts: 365
If you use a SEF component like sh404SEF. Why would you want to change it?

_________________
Best regards, Kristoffer Sandven

http://www.joomlablogger.net/
http://www.twitter.com/joomlablogger


Top
 Profile  
 
PostPosted: Sun Sep 06, 2009 9:11 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun May 18, 2008 10:18 am
Posts: 25
Location: Finland
i am using system SEF and i want to change it because i had before htm pages on my site and all google links refer to them.
Links from Google Search work at once that way and dont need to wait for the update


Top
 Profile  
 
PostPosted: Mon Sep 28, 2009 3:07 pm 
Joomla! Intern
Joomla! Intern

Joined: Wed Sep 26, 2007 6:11 pm
Posts: 55
Location: Indianapolis
Did anyone figure this out? My client has indexed urls using .htm and he wants the site im rebuilding him to use the exact same links.

I do not want to use sh404, only the Joomla SEF. And i have the links perfect, excecpt for .html instead of .htm.

Any ideas?

_________________
Only exact URLs allowed in signature. Please read Forum Rules: viewtopic.php?f=8&t=65


Top
 Profile  
 
PostPosted: Mon Sep 28, 2009 3:50 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun May 18, 2008 10:18 am
Posts: 25
Location: Finland
If all those .htm are under the root you can use this:

make a new menu, I call it hiddenmenu because I will not use it.
then make new links in this menu to your content, article

If You have an Article with Alias called News the link
http://www.domain.com/news.htm will go to this article.

Other wise You have to force yourself to make redirect html files, not so nice but works.


Top
 Profile  
 
PostPosted: Mon Sep 28, 2009 7:25 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun May 18, 2008 10:18 am
Posts: 25
Location: Finland
Its good to have the redirects to your new content, because Google still shows you the old site links a while or two.


Top
 Profile  
 
PostPosted: Fri May 07, 2010 8:04 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Jul 14, 2008 1:39 pm
Posts: 41
hi,
not sure but it seems that these don't really answer to the question here... I'm trying to do the same thing:
joomla SEF creating urls with .htm instead of .html
Is there actually a way to change that.
That was the question right? it's also my question but I don't see a concrete solution here.
Kindly
Max

_________________
http://www.rootshosting.net


http://www.khmer-dev.com



Top
 Profile  
 
PostPosted: Fri May 07, 2010 8:36 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Sun Oct 02, 2005 12:50 am
Posts: 17558
Location: Omaha, NE
http://docs.joomla.org/SEO scroll down towards the bottom of the page

_________________
Regards, Dave
http://www.kiwaniswest.org
http://www.huelsmann.us


Top
 Profile  
 
PostPosted: Wed May 19, 2010 4:41 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 27, 2010 6:38 pm
Posts: 14
I tried the patch recommended in the previous post. I received an error message that there was an extra comma (,) in line 60. So I changed the code from

$path = str_replace('.'.$suffix, , $path);

to

$path = str_replace('.'.$suffix, '', $path);

Now I don't get an error message, but the .htm suffix is now appended to the URL (.html.htm). I don't know php, so how do I replace .html with .htm?


Top
 Profile  
 
PostPosted: Wed May 19, 2010 5:08 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sun Oct 02, 2005 12:50 am
Posts: 17558
Location: Omaha, NE
Looks like it should have been
Code:
$path = str_replace('.'.$suffix, '', $path);

_________________
Regards, Dave
http://www.kiwaniswest.org
http://www.huelsmann.us


Top
 Profile  
 
PostPosted: Wed May 19, 2010 6:17 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 27, 2010 6:38 pm
Posts: 14
That's what I did change it to (unless I'm missing something), but the .html was appended to, not replaced.


Top
 Profile  
 
PostPosted: Wed May 19, 2010 6:21 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sun Oct 02, 2005 12:50 am
Posts: 17558
Location: Omaha, NE
Hmmm, that's not what was showing earlier. This is what I saw in your post
Code:
$path = str_replace('.'.$suffix, $path);

_________________
Regards, Dave
http://www.kiwaniswest.org
http://www.huelsmann.us


Top
 Profile  
 
PostPosted: Wed May 19, 2010 6:33 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 27, 2010 6:38 pm
Posts: 14
What I wrote was:

So I changed the code from $path = str_replace('.'.$suffix, , $path);

to $path = str_replace('.'.$suffix, '', $path);

It seems to me that I changed it to what you wrote, but code makes my eyes hurt. Maybe I'm still missing something!


Top
 Profile  
 
PostPosted: Wed May 19, 2010 6:40 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Sun Oct 02, 2005 12:50 am
Posts: 17558
Location: Omaha, NE
Did you change it in all of its instances?
Code:
{
                                if($suffix = pathinfo($path, PATHINFO_EXTENSION))
                                {
-                                       $path = str_replace('.'.$suffix,'' , $path);
-                                       $vars['format'] = $suffix;
+                                       if ($suffix == 'htm') {
+                                               $path = str_replace('.'.$suffix,'' , $path);
+                                               $vars['format'] = 'html';
+                                       } else {
+                                               $path = str_replace('.'.$suffix,'' , $path);
+                                               $vars['format'] = $suffix;
+                                       }
                                }
                        }

_________________
Regards, Dave
http://www.kiwaniswest.org
http://www.huelsmann.us


Top
 Profile  
 
PostPosted: Wed May 26, 2010 12:54 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 27, 2010 6:38 pm
Posts: 14
Yes, I did change it in all instances. Still the .htm is appended to the .html


Top
 Profile  
 
PostPosted: Tue Jun 01, 2010 3:14 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 27, 2010 6:38 pm
Posts: 14
Has anyone figured this out yet or gotten it to work? I copied the text above exactly and still ".htm" is appended to ".html". Very frustrating!!


Top
 Profile  
 
PostPosted: Sun Jun 20, 2010 10:21 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Mar 03, 2010 9:24 am
Posts: 3
Hmm I need to get this working as well I tried it and no joy either. has anyone got this working as yet?


Top
 Profile  
 
PostPosted: Mon Jun 28, 2010 10:54 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu May 01, 2008 12:36 pm
Posts: 1111
Location: QubeSys Technologies Pvt. Ltd ,INDIA
There is no instruction, where and which line to change or paste or replace, anything on the docs site. DAMN!

Here is the bew router.php file in Joomla 1.5.18

Now, can anyone paste the fixed version of it with htm modifications ?

Code:
<?php
/**
* @version      $Id: router.php 8180 2007-07-23 05:52:29Z eddieajau $
* @package      Joomla.Framework
* @subpackage   Application
* @copyright   Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license      GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

/**
 * Class to create and parse routes for the site application
 *
 * @package    Joomla
 * @since      1.5
 */
class JRouterSite extends JRouter
{
   /**
    * Class constructor
    *
    * @access public
    */
   function __construct($options = array()) {
      parent::__construct($options);
   }

   function parse(&$uri)
   {
      $vars = array();

      // Get the application
      $app =& JFactory::getApplication();

      if($app->getCfg('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         //forward to https
         $uri->setScheme('https');
         $app->redirect($uri->toString());
      }


      // Get the path
      $path = $uri->getPath();

      //Remove the suffix
      if($this->_mode == JROUTER_MODE_SEF)
      {

         if($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/'))
         {
            if($suffix = pathinfo($path, PATHINFO_EXTENSION))
            {
               $path = str_replace('.'.$suffix, '', $path);
               $vars['format'] = $suffix;
            }
         }
      }

      //Remove basepath
      $path = substr_replace($path, '', 0, strlen(JURI::base(true)));

      //Remove prefix
      $path = str_replace('index.php', '', $path);

      //Set the route
      $uri->setPath(trim($path , '/'));

      $vars += parent::parse($uri);

      return $vars;
   }

   function &build($url)
   {
      $uri =& parent::build($url);

      // Get the path data
      $route = $uri->getPath();

      //Add the suffix to the uri
      if($this->_mode == JROUTER_MODE_SEF && $route)
      {
         $app =& JFactory::getApplication();

         if($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/'))
         {
            if($format = $uri->getVar('format', 'html'))
            {
               $route .= '.'.$format;
               $uri->delVar('format');
            }
         }

         if($app->getCfg('sef_rewrite'))
         {
            //Transform the route
            $route = str_replace('index.php/', '', $route);
         }
      }

      //Add basepath to the uri
      $uri->setPath(JURI::base(true).'/'.$route);

      return $uri;
   }

   function _parseRawRoute(&$uri)
   {
      $vars   = array();

      $menu =& JSite::getMenu(true);

      //Handle an empty URL (special case)
      if(!$uri->getVar('Itemid') && !$uri->getVar('option'))
      {
         $item = $menu->getDefault();
         if(!is_object($item)) return $vars; // No default item set

         //Set the information in the request
         $vars = $item->query;

         //Get the itemid
         $vars['Itemid'] = $item->id;

         // Set the active menu item
         $menu->setActive($vars['Itemid']);

         return $vars;
      }

      //Get the variables from the uri
      $this->setVars($uri->getQuery(true));

      //Get the itemid, if it hasn't been set force it to null
      $this->setVar('Itemid', JRequest::getInt('Itemid', null));

      //Only an Itemid ? Get the full information from the itemid
      if(count($this->getVars()) == 1)
      {
         $item = $menu->getItem($this->getVar('Itemid'));
         if($item !== NULL && is_array($item->query)) {
            $vars = $vars + $item->query;
         }
      }

      // Set the active menu item
      $menu->setActive($this->getVar('Itemid'));

      return $vars;
   }

   function _parseSefRoute(&$uri)
   {
      $vars   = array();

      $menu  =& JSite::getMenu(true);
      $route = $uri->getPath();

      //Get the variables from the uri
      $vars = $uri->getQuery(true);

      //Handle an empty URL (special case)
      if(empty($route))
      {

         //If route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately
         if(isset($vars['option']) || isset($vars['Itemid'])) {
            return $this->_parseRawRoute($uri);
         }

         $item = $menu->getDefault();

         //Set the information in the request
         $vars = $item->query;

         //Get the itemid
         $vars['Itemid'] = $item->id;

         // Set the active menu item
         $menu->setActive($vars['Itemid']);

         return $vars;
      }


      /*
       * Parse the application route
       */

      if(substr($route, 0, 9) == 'component')
      {
         $segments   = explode('/', $route);
         $route      = str_replace('component/'.$segments[1], '', $route);

         $vars['option'] = 'com_'.$segments[1];
         $vars['Itemid'] = null;
      }
      else
      {
         //Need to reverse the array (highest sublevels first)
         $items = array_reverse($menu->getMenu());

         foreach ($items as $item)
         {
            $lenght = strlen($item->route); //get the lenght of the route

            if($lenght > 0 && strpos($route.'/', $item->route.'/') === 0 && $item->type != 'menulink')
            {
               $route   = substr($route, $lenght);

               $vars['Itemid'] = $item->id;
               $vars['option'] = $item->component;
               break;
            }
         }
      }

      // Set the active menu item
      if ( isset($vars['Itemid']) ) {
         $menu->setActive(  $vars['Itemid'] );
      }

      //Set the variables
      $this->setVars($vars);

      /*
       * Parse the component route
       */
      if(!empty($route) && isset($this->_vars['option']) )
      {
         $segments = explode('/', $route);
         array_shift($segments);

         // Handle component   route
         $component = preg_replace('/[^A-Z0-9_\.-]/i', '', $this->_vars['option']);

         // Use the component routing handler if it exists
         $path = JPATH_SITE.DS.'components'.DS.$component.DS.'router.php';

         if (file_exists($path) && count($segments))
         {
            if ($component != "com_search") { // Cheap fix on searches
               //decode the route segments
               $segments = $this->_decodeSegments($segments);
            }
            else { // fix up search for URL
               $total = count($segments);
               for($i=0; $i<$total; $i++) {
                  // urldecode twice because it is encoded twice
                  $segments[$i] = urldecode(urldecode(stripcslashes($segments[$i])));
               }
            }

            require_once $path;
            $function =  substr($component, 4).'ParseRoute';
            $vars =  $function($segments);

            $this->setVars($vars);
         }
      }
      else
      {
         //Set active menu item
         if($item =& $menu->getActive()) {
            $vars = $item->query;
         }
      }

      return $vars;
   }

   function _buildRawRoute(&$uri)
   {
   }

   function _buildSefRoute(&$uri)
   {
      // Get the route
      $route = $uri->getPath();

      // Get the query data
      $query = $uri->getQuery(true);

      if(!isset($query['option'])) {
         return;
      }

      $menu =& JSite::getMenu();

      /*
       * Build the component route
       */
      $component   = preg_replace('/[^A-Z0-9_\.-]/i', '', $query['option']);
      $tmp       = '';

      // Use the component routing handler if it exists
      $path = JPATH_SITE.DS.'components'.DS.$component.DS.'router.php';

      // Use the custom routing handler if it exists
      if (file_exists($path) && !empty($query))
      {
         require_once $path;
         $function   = substr($component, 4).'BuildRoute';
         $parts      = $function($query);

         // encode the route segments
         if ($component != "com_search") { // Cheep fix on searches
            $parts = $this->_encodeSegments($parts);
         }
         else { // fix up search for URL
            $total = count($parts);
            for($i=0; $i<$total; $i++) {
               // urlencode twice because it is decoded once after redirect
               $parts[$i] = urlencode(urlencode(stripcslashes($parts[$i])));
            }
         }

         $result = implode('/', $parts);
         $tmp   = ($result != "") ? '/'.$result : '';
      }

      /*
       * Build the application route
       */
      $built = false;
      if (isset($query['Itemid']) && !empty($query['Itemid']))
      {
         $item = $menu->getItem($query['Itemid']);

         if (is_object($item) && $query['option'] == $item->component) {
            $tmp = !empty($tmp) ? $item->route.'/'.$tmp : $item->route;
            $built = true;
         }
      }

      if(!$built) {
         $tmp = 'component/'.substr($query['option'], 4).'/'.$tmp;
      }

      $route .= '/'.$tmp;

      // Unset unneeded query information
      unset($query['Itemid']);
      unset($query['option']);

      //Set query again in the URI
      $uri->setQuery($query);
      $uri->setPath($route);
   }

   function _processParseRules(&$uri)
   {
      // Process the attached parse rules
      $vars = parent::_processParseRules($uri);

      // Process the pagination support
      if($this->_mode == JROUTER_MODE_SEF)
      {
         $app =& JFactory::getApplication();

         if($start = $uri->getVar('start'))
         {
            $uri->delVar('start');
            $vars['limitstart'] = $start;
         }
      }

      return $vars;
   }

   function _processBuildRules(&$uri)
   {
      // Make sure any menu vars are used if no others are specified
      if(($this->_mode != JROUTER_MODE_SEF) && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2)
      {
         $menu =& JSite::getMenu();

         // Get the active menu item
         $itemid = $uri->getVar('Itemid');
         $item   = $menu->getItem($itemid);

         $uri->setQuery($item->query);
         $uri->setVar('Itemid', $itemid);
      }

      // Process the attached build rules
      parent::_processBuildRules($uri);

      // Get the path data
      $route = $uri->getPath();

      if($this->_mode == JROUTER_MODE_SEF && $route)
      {
         $app =& JFactory::getApplication();

         if ($limitstart = $uri->getVar('limitstart'))
         {
            $uri->setVar('start', (int) $limitstart);
            $uri->delVar('limitstart');
         }
      }

      $uri->setPath($route);
   }

   function &_createURI($url)
   {
      //Create the URI
      $uri =& parent::_createURI($url);

      // Set URI defaults
      $menu =& JSite::getMenu();

      // Get the itemid form the URI
      $itemid = $uri->getVar('Itemid');

      if(is_null($itemid))
      {
         if($option = $uri->getVar('option'))
         {
            $item  = $menu->getItem($this->getVar('Itemid'));
            if(isset($item) && $item->component == $option) {
               $uri->setVar('Itemid', $item->id);
            }
         }
         else
         {
            if($option = $this->getVar('option')) {
               $uri->setVar('option', $option);
            }

            if($itemid = $this->getVar('Itemid')) {
               $uri->setVar('Itemid', $itemid);
            }
         }
      }
      else
      {
         if(!$uri->getVar('option'))
         {
            $item  = $menu->getItem($itemid);
            $uri->setVar('option', $item->component);
         }
      }

      return $uri;
   }
}

_________________
http://www.qubesys.com : Web Design, eCommerce and Software Development
http://www.joomclub.org : Joomla Premium Extensions,Templates and Support Packages


Top
 Profile  
 
PostPosted: Mon Jun 28, 2010 11:37 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu May 01, 2008 12:36 pm
Posts: 1111
Location: QubeSys Technologies Pvt. Ltd ,INDIA
I trie4d the above thingy and its giving html.htm

Damn..

_________________
http://www.qubesys.com : Web Design, eCommerce and Software Development
http://www.joomclub.org : Joomla Premium Extensions,Templates and Support Packages


Top
 Profile  
 
PostPosted: Mon Jun 28, 2010 11:54 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu May 01, 2008 12:36 pm
Posts: 1111
Location: QubeSys Technologies Pvt. Ltd ,INDIA
Anyone got a solution to this ,
This doesnt work anymore in Joomla 1.5.18 :
http://docs.joomla.org/SEO#Change_defau ... ml_to_.htm

_________________
http://www.qubesys.com : Web Design, eCommerce and Software Development
http://www.joomclub.org : Joomla Premium Extensions,Templates and Support Packages


Top
 Profile  
 
PostPosted: Mon Jun 28, 2010 12:04 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu May 01, 2008 12:36 pm
Posts: 1111
Location: QubeSys Technologies Pvt. Ltd ,INDIA
Solved it. Writing the tutorial in my site now. Will post a link then. Thanks.

_________________
http://www.qubesys.com : Web Design, eCommerce and Software Development
http://www.joomclub.org : Joomla Premium Extensions,Templates and Support Packages


Top
 Profile  
 
PostPosted: Tue Jun 29, 2010 7:04 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Jun 24, 2010 12:26 am
Posts: 3
Location: Philippines
Code:
$path = str_replace('.'.$suffix, '', $path);

_________________
Voiceville Communications, Inc.
http://www.voicevilleinc.com
http://july-buzz-portal.[URL banned].com/


Top
 Profile  
 
PostPosted: Tue Jun 29, 2010 7:11 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Tue Apr 01, 2008 11:15 pm
Posts: 75
Location: Orange County, California
When using Artio Joomsef just got to global configuration and list the extension you want under "File Suffix".

_________________
Scot Trodick, MAOM, MACBT, GHRM, BFA
http://www.ProConsultancy.com
Web Design, eCommerce and Search Engine Placement
Orange County Digital Arts - http://www.OCDigitalArts.com


Top
 Profile  
 
PostPosted: Tue Jun 29, 2010 12:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 27, 2010 6:38 pm
Posts: 14
SOAMJENA wrote:
Solved it. Writing the tutorial in my site now. Will post a link then. Thanks.


Looking forward to seeing this!!


Top
 Profile  
 
PostPosted: Wed Nov 10, 2010 4:02 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Nov 10, 2010 4:00 am
Posts: 1
will wait for this too..


Top
 Profile  
 
PostPosted: Mon May 07, 2012 4:21 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 14, 2008 8:22 pm
Posts: 25
I know I'm Resurrection an old thread, but I'm surprised this basic functionality doesn't exist in Joomla yet but then, there's many things that don't exist in Joomla that seem fundamental such as content versioning..

People keep recommending the move to Artio or sh404SEF, which I get .. since they are really the only options for accomplishing the task without hacking the core code which I am completely against suggesting since that can make upgrading a risk.

I've used sh404SEF in the past and found it to be overkill for my needs, but not only that.. it often caused problems such as 500 errors on certain menu links or SEF urls simply not working out of the blue.. there's something to be said about the simplicity of Joomla's built in SEF.. if only it didn't lack the ability to customize the suffix...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ] 



Who is online

Users browsing this forum: No registered users and 10 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