Post by Rappuzzi » Fri Dec 14, 2012 8:39 am

smifis wrote:I have my own script which i use on the sites I make.
Hello smifis.
I've no idea what's "the lates version"? But since this post is just recent, I assume you all talk about 1.5.4.1. If that's the case, it does not work at all, I still have teh ugly /index.php?route=common/ showing. Yes. I'd enabled SEO friendly URL's in admin/settings. And yes, I have a clean (nothing added yet) basic sample OC theme that comes with the download ...?

Instead;
it only throws an error... The requested URL /opencart1541/product/product.php/blablabla/ was not found on this server.

Seems to be an extreme complicated, standing and unsolved" issue that many people have and cannot be fixed..., otherwise you wouldn't need to spend hours and hours searching this forum and on Google, and on Bing, and on Yahoo, and reading dozens and dozens of "assumed" fixes... hm...? - is there ANY solution to that at all and can someone just point to that solution without having to read another dozens of posts ending all in a dead end?

What a pity.
:-\

Much appreciated

Newbie

Posts

Joined
Wed Jun 27, 2012 7:22 am

Post by smifis » Fri Dec 14, 2012 11:46 am

I can confirm it does work, and works on many sites too.

If you send me a PM I'll see if we can sort your problem out, and yes, I meant opencart 1.5.4.1 but the same script works on version all the way back to version 1.4.9.x

Active Member

Posts

Joined
Sat Jan 15, 2011 10:37 pm


Post by anung » Sat Dec 15, 2012 7:04 pm

Chang this code

Code: Select all

$url .=  '/contact';
to be

Code: Select all

$url .=  '/kontakt';

User avatar
Active Member

Posts

Joined
Fri Mar 30, 2012 10:32 am
Location - Indonesia

Post by harry8888 » Wed Dec 19, 2012 1:35 am

I did try your code with OC 1.5.4.1 (latest) and worked well. Thank you !!

Is it possible to remove the .PHP extension? Please share your thoughts.
Also your code to detect HTTPS vs HTTP is throwing an error in my environment without HTTPS.

Thanks,

Harry
smifis wrote:We have just finished a new 'fixed' version.

Code: Select all

<?php
class ControllerCommonSeoUrl extends Controller {
   public function index() {
      // Add rewrite to url class
      if ($this->config->get('config_seo_url')) {
         $this->url->addRewrite($this);
      }
      
      // Decode URL
      if (isset($this->request->get['_route_'])) {
         $parts2 = explode('.php', $this->request->get['_route_']);
		 
         $parts = explode('/', $parts2[0]);
         foreach ($parts as $part) {
         $part = rtrim($part,'.php');
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
            
            if ($query->num_rows) {
               $url = explode('=', $query->row['query']);
               
               if ($url[0] == 'product_id') {
                  $this->request->get['product_id'] = $url[1];
               }
               
               if ($url[0] == 'category_id') {
                  if (!isset($this->request->get['path'])) {
                     $this->request->get['path'] = $url[1];
                  } else {
                     $this->request->get['path'] .= '_' . $url[1];
                  }
               }   
               
               if ($url[0] == 'manufacturer_id') {
                  $this->request->get['manufacturer_id'] = $url[1];
               }
               
               if ($url[0] == 'information_id') {
                  $this->request->get['information_id'] = $url[1];
               }   
            } else {
               $this->request->get['route'] = 'error/not_found';   
            }
         }
		 
         if (isset($this->request->get['product_id'])) {
            $this->request->get['route'] = 'product/product';
         } elseif (isset($this->request->get['path'])) {
            $this->request->get['route'] = 'product/category';
         } elseif (isset($this->request->get['manufacturer_id'])) {
            $this->request->get['route'] = 'product/manufacturer/info';
         } elseif (isset($this->request->get['information_id'])) {
            $this->request->get['route'] = 'information/information';
         } 
		if (isset($this->request->get['route'])) {
            $this->request->get['route'] = $parts2[0];
         }
         if (isset($parts2[1])) {
            $par = explode('/',$parts2[1]);
            unset($par[0]);
            
            $par = array_values($par);
            
            $nextpara = '';
            foreach( $par as $key => $value ) {
               if( 0 === $key%2) { //Even
                  $nextpara = $value;
               }
               else {
                  $this->request->get[$nextpara] = $value;
               }
            }
         }
         
         if (isset($this->request->get['route'])) {
            return $this->forward($this->request->get['route']);
         }
      } elseif(isset($this->request->get['route'])){
         if ($this->request->get['route'] =='product/search') {
            $pageURL = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
            if ($_SERVER["SERVER_PORT"] != "80")
            {
               $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
            } 
            else 
            {
               $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
            }
            $this->redirect($this->rewrite($pageURL));
         }
      }
   }
   
   public function rewrite($link) {
      if ($this->config->get('config_seo_url')) {
         $url_data = parse_url(str_replace('&', '&', $link));
      
         $url = ''; 
         
         $data = array();
         
         parse_str($url_data['query'], $data);
         
         foreach ($data as $key => $value) {
            if (isset($data['route'])) {
               if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
                  $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
               
                  if ($query->num_rows) {
                     $url .= '/' . $query->row['keyword'];
                     
                     unset($data[$key]);
                  }               
               } elseif ($key == 'path') {
                  $categories = explode('_', $value);
                  
                  foreach ($categories as $category) {
                     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
               
                     if ($query->num_rows) {
                        $url .= '/' . $query->row['keyword'];
                     }                     
                  }
                  
                  //unset($data[$key]);
               }
            }
         }
      
         if ($url) {
            unset($data['route']);
         
            $query = '';
            
            if(count($data)> 0) {
            
               foreach ($data as $key => $value) {
                  $query .= '/'.$key.'/'.$value; 
               }
            }

            return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . '.php'. $query;
         } else {
            
            $url_data = parse_url(str_replace('&', '&', $link));
      
            $url = '/'; 
            
            $data = array();
            
            parse_str($url_data['query'], $data);
			
         
            $url .= $data['route'] . '.php';
            unset($data['route']);
            
            if(count($data)> 0) {
			
            
               foreach ($data as $key => $value) {
                  $url .= '/'.$key.'/'.$value;
               }
            }
			
            return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url;
         }
      } else {
         return $link;
      }      
   }   
}
?>

Newbie

Posts

Joined
Wed Dec 19, 2012 1:28 am

Post by speedy » Wed Jan 02, 2013 5:51 pm

Do not work on OC 1.5.4 with vqmod.

New member

Posts

Joined
Thu Jul 28, 2011 1:23 am

Post by Axansh » Thu Jan 03, 2013 3:09 pm

Hi,

We have developed an extension for SEO - to make it easy for seller.

This module helps you with optimizing the url's of all your website pages , categories , products , manufacturers , information pages .

you can also optimize the titles , meta tag keywords , meta tag descriptions of all the links , categories , products , manufacturers , information pages .

If you add new links or catalog data - they can be optimised as well .

All optimizations can be done for multiple languages .

Image names can also be optimized .

For fast results , less data entry - you can use auto generate facility

Thanks and Best Regards,
Axansh Sheth

Our Opencart Module
All in ONE SEO |
Multi-purpose pop |
Restaurant theme |
Store time save module


User avatar
Active Member

Posts

Joined
Mon Feb 06, 2012 3:07 pm

Post by smifis » Sat Jan 12, 2013 12:33 am

harry8888 wrote:I did try your code with OC 1.5.4.1 (latest) and worked well. Thank you !!

Is it possible to remove the .PHP extension? Please share your thoughts.
Also your code to detect HTTPS vs HTTP is throwing an error in my environment without HTTPS.

Thanks,

Harry
smifis wrote:We have just finished a new 'fixed' version.

Code: Select all

<?php
class ControllerCommonSeoUrl extends Controller {
   public function index() {
      // Add rewrite to url class
      if ($this->config->get('config_seo_url')) {
         $this->url->addRewrite($this);
      }
      
      // Decode URL
      if (isset($this->request->get['_route_'])) {
         $parts2 = explode('.php', $this->request->get['_route_']);
		 
         $parts = explode('/', $parts2[0]);
         foreach ($parts as $part) {
         $part = rtrim($part,'.php');
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
            
            if ($query->num_rows) {
               $url = explode('=', $query->row['query']);
               
               if ($url[0] == 'product_id') {
                  $this->request->get['product_id'] = $url[1];
               }
               
               if ($url[0] == 'category_id') {
                  if (!isset($this->request->get['path'])) {
                     $this->request->get['path'] = $url[1];
                  } else {
                     $this->request->get['path'] .= '_' . $url[1];
                  }
               }   
               
               if ($url[0] == 'manufacturer_id') {
                  $this->request->get['manufacturer_id'] = $url[1];
               }
               
               if ($url[0] == 'information_id') {
                  $this->request->get['information_id'] = $url[1];
               }   
            } else {
               $this->request->get['route'] = 'error/not_found';   
            }
         }
		 
         if (isset($this->request->get['product_id'])) {
            $this->request->get['route'] = 'product/product';
         } elseif (isset($this->request->get['path'])) {
            $this->request->get['route'] = 'product/category';
         } elseif (isset($this->request->get['manufacturer_id'])) {
            $this->request->get['route'] = 'product/manufacturer/info';
         } elseif (isset($this->request->get['information_id'])) {
            $this->request->get['route'] = 'information/information';
         } 
		if (isset($this->request->get['route'])) {
            $this->request->get['route'] = $parts2[0];
         }
         if (isset($parts2[1])) {
            $par = explode('/',$parts2[1]);
            unset($par[0]);
            
            $par = array_values($par);
            
            $nextpara = '';
            foreach( $par as $key => $value ) {
               if( 0 === $key%2) { //Even
                  $nextpara = $value;
               }
               else {
                  $this->request->get[$nextpara] = $value;
               }
            }
         }
         
         if (isset($this->request->get['route'])) {
            return $this->forward($this->request->get['route']);
         }
      } elseif(isset($this->request->get['route'])){
         if ($this->request->get['route'] =='product/search') {
            $pageURL = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
            if ($_SERVER["SERVER_PORT"] != "80")
            {
               $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
            } 
            else 
            {
               $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
            }
            $this->redirect($this->rewrite($pageURL));
         }
      }
   }
   
   public function rewrite($link) {
      if ($this->config->get('config_seo_url')) {
         $url_data = parse_url(str_replace('&', '&', $link));
      
         $url = ''; 
         
         $data = array();
         
         parse_str($url_data['query'], $data);
         
         foreach ($data as $key => $value) {
            if (isset($data['route'])) {
               if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
                  $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
               
                  if ($query->num_rows) {
                     $url .= '/' . $query->row['keyword'];
                     
                     unset($data[$key]);
                  }               
               } elseif ($key == 'path') {
                  $categories = explode('_', $value);
                  
                  foreach ($categories as $category) {
                     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
               
                     if ($query->num_rows) {
                        $url .= '/' . $query->row['keyword'];
                     }                     
                  }
                  
                  //unset($data[$key]);
               }
            }
         }
      
         if ($url) {
            unset($data['route']);
         
            $query = '';
            
            if(count($data)> 0) {
            
               foreach ($data as $key => $value) {
                  $query .= '/'.$key.'/'.$value; 
               }
            }

            return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . '.php'. $query;
         } else {
            
            $url_data = parse_url(str_replace('&', '&', $link));
      
            $url = '/'; 
            
            $data = array();
            
            parse_str($url_data['query'], $data);
			
         
            $url .= $data['route'] . '.php';
            unset($data['route']);
            
            if(count($data)> 0) {
			
            
               foreach ($data as $key => $value) {
                  $url .= '/'.$key.'/'.$value;
               }
            }
			
            return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url;
         }
      } else {
         return $link;
      }      
   }   
}
?>
Wherever you have

Code: Select all

'.php'
replace it with

Code: Select all

''

Active Member

Posts

Joined
Sat Jan 15, 2011 10:37 pm


Post by tresero » Tue Jan 15, 2013 1:26 am

That has a slight bug if you take the .php out of line 11.

also, is there a way to get rid of common/home and just have a normal home page url?

Newbie

Posts

Joined
Sat Jan 12, 2013 3:24 am

Post by fullphat » Wed Jan 16, 2013 12:05 am

I would love to know this as well Matte2k, Ill see if i can find this out now and post if i find a fix

User avatar
New member

Posts

Joined
Wed Oct 19, 2011 4:47 pm

Post by smifis » Wed Jan 23, 2013 12:19 am

tresero wrote:That has a slight bug if you take the .php out of line 11.

also, is there a way to get rid of common/home and just have a normal home page url?
could you tell me what this bug is?

And I'll stick that in the next release.

Active Member

Posts

Joined
Sat Jan 15, 2011 10:37 pm


Post by jcb_chl » Tue Jan 29, 2013 4:59 pm

Hello smifis,
I tried your script. seo urls are generated but when i click on the links correct page is not loading. Please help to rectify this. My website is www.cbn.in/shop/
Thanks,
Jacob

Newbie

Posts

Joined
Tue Jan 29, 2013 3:23 pm

Post by ibietela » Sun Feb 03, 2013 4:28 am

fullphat wrote:Hi guys,

Just to update everyone, I got this working with the generous help from Anung off the forum who provided me with the attached file which goes in vqmod/xml

This fixed all my URL's to be search engine friendly

Thanks again for the help,
Martin
Hi Martin... How did you do it? Mine is not working dont know why.

New member

Posts

Joined
Fri Nov 09, 2012 12:39 am

Post by YaegerDesign » Sat Feb 09, 2013 1:22 pm

fullphat wrote:Hi guys,

Just to update everyone, I got this working with the generous help from Anung off the forum who provided me with the attached file which goes in vqmod/xml

This fixed all my URL's to be search engine friendly

Thanks again for the help,
Martin
Thanks!!! SEO URLs solved! :D

Newbie

Posts

Joined
Sat Feb 09, 2013 1:19 pm

Post by Ann72 » Thu Mar 21, 2013 8:45 pm

Just dropping a BIG thank you, this file worked perfect!!!! :) All my url's are now seo friendly!

Newbie

Posts

Joined
Tue Mar 19, 2013 2:33 pm

Post by Dunald » Wed May 22, 2013 5:43 pm

Hi!
Thanks a lot it works almost great.
When I go to my site and log in as a user I still have the index.php?route in these files:

http://www.MYSITE.com/index.php?route=account/password

and

http://www.MYSITE.com/index.php?route=account/edit

and

http://www.MYSITE.com/index.php?route=account/address

and

http://www.MYSITE.com/min/index.php?b=c ... custom.css

and

http://www.MYSITE.com/min/index.php?b=c ... ,common.js

How do I remove the index.php?route from here? ???
I am using the latest opencart.
/Thanks

Active Member

Posts

Joined
Tue Mar 15, 2011 9:05 pm

Post by Dunald » Tue Jun 25, 2013 10:04 pm

Hello again!
Any news?

I get this small problem when my customers delete a product from the cart: They are redirected to the "Cant find product" instead of remaining in the cart. Any idea how to fix this?

Active Member

Posts

Joined
Tue Mar 15, 2011 9:05 pm

Post by syamsul111 » Fri Nov 22, 2013 10:24 am

anung wrote:I think you need this tutorial
http://forum.opencart.com/viewtopic.php?f=20&t=39580

mas anung >> mohon penjelasannya. bagaimana cara membuat URL menjadi SEO dan cantik.?? mohon di jelaskan tahapannya , step to step supaya kami paham maksudnya. harus membuka apa?? harus edit apa???

opencart 1.4.9.6
http://www.tokolemka.com/

sebab url informasi punya saya masih ngacak seperti ini mas:
http://www.tokolemka.com/index.php?route=checkout/cart
http://www.tokolemka.com/index.php?rout ... on/contact
http://www.tokolemka.com/index.php?rout ... tion_id=12
http://www.tokolemka.com/index.php?rout ... tion_id=19
dll

kalau url produk, kategori, sudah bagus. seperti ini :
http://www.tokolemka.com/posca-164
http://www.tokolemka.com/rotring-165

Newbie

Posts

Joined
Fri Jul 06, 2012 4:53 am

Post by anung » Thu Dec 05, 2013 9:18 am

Untuk OpenCart v.1.4.9.6 saya kurang paham, tutorial diatas untuk OpenCart v.1.5.x.x.

User avatar
Active Member

Posts

Joined
Fri Mar 30, 2012 10:32 am
Location - Indonesia

Post by pulkitarun » Sat Dec 26, 2015 4:21 pm

Hi Smifis ,

I used your old version old for removing '/index.php?route=' from '/index.php?route=information/sitemap'. It has remove the /index.php?route= from all the urls from my webiste (https://www.laxminarayaninternational.com).

But it causes .php add to other url of the website. All other url stop working add this .php get added on the url of pages, category and and products.

Kindly help me out to solve it

Newbie

Posts

Joined
Sat Dec 26, 2015 4:04 pm
Who is online

Users browsing this forum: No registered users and 47 guests