Post by ozone100 » Sun Apr 24, 2011 2:45 am

Is it possible to add a trailing slash at the end of URLs?

I have a background in SEO and I am a perfectionist when it comes factors that could negative affect a pages ability to rank. In Google's eyes, http://www.beerpongstadium.com/about is a different page than http://www.beerpongstadium.com/about/. That said, I want all pages to end with a trailing slash. Anyone know how I could add this trailing slash at the end of URLs while keeping my urls seo friendly?

Thanks.

New member

Posts

Joined
Fri Apr 22, 2011 9:21 am

Post by Xsecrets » Sun Apr 24, 2011 3:29 am

while I get that about is a different page to about/ in googles eyes who ever said that the trailing slash helps seo?

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by ozone100 » Sun Apr 24, 2011 4:07 am

The trailing slash helps seo because it creates only one version of the page...it's a canonical issue.

It does a few things:
- It lets google know which version of the page is the actual version
- It avoids duplicate content issues and penalties associated with duplicate content (pages aren't competing to rank for the same keyword)
- It condenses "link juice," if you have links to mysite.com/page and mysite.com/page/ they are being divided rather than consolidated. Links are the biggest factor in ranking a page so every little bit helps.

New member

Posts

Joined
Fri Apr 22, 2011 9:21 am

Post by ozone100 » Mon Apr 25, 2011 5:47 am

So since it is useful for rankings to have a trailing slash at the end of a URL, does anyone know how to do this?

New member

Posts

Joined
Fri Apr 22, 2011 9:21 am

Post by Xsecrets » Mon Apr 25, 2011 5:58 am

it has no affect whatsoever on link duplication or canonical issues. As long as all your links are the same it makes no difference if they have the trailing slash or not.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by boltsabre » Wed Apr 27, 2011 2:29 am

sorry, but ozone100 is spot on, it does make a difference - a big differnce. If you have 100 inbound links and:
- 25 link to: http://www.mypage.com/about
- 25 link to: http://www.mypage.com/about/
- 25 link to: www.mypage.com/about
- 25 link to: www.mypage.com/about/
Then effectivley you are only gaining 25 links to a 'page' instead of the full 100 links. The page is the same as far as content is concerned, yet google does not see it as such, it sees four different pages, and in fact your site can be penalised for duplicate content issues in such a situation - you MUST have an effective .htaccess (for appache server) plan in place with permanent redirects so the user is always directed to your desired version of the url. And it's also a good idea to regularly check back links to the other url versions, and if any exist send the webmaster a nice email and ask them to change the link to your preferred format to gain the most SEO benefit available.

Newbie

Posts

Joined
Wed Apr 27, 2011 2:23 am

Post by Xsecrets » Wed Apr 27, 2011 3:21 am

well why would any of the links go to different places if all your pages are rewritten the same? if it's just the person on the other site manually putting in the wrong url. They could just as easily put in the url without the / as to put it in with the /. My argument was never that you don't need htaccess redirects simply that weather with or without the / as long as they are always the same it doesn't matter.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by ozone100 » Sun May 01, 2011 8:52 am

Xsecrets is correct. All that matters is that you have one format. I usually prefer www.sample.com/ for home and www.sample.com/page/ for pages. Only thing is that I don't know how to redirect it to one or the other...when working with clients their developers deal with the technical aspect. Anyone know how to automatically add the slash at the end?

New member

Posts

Joined
Fri Apr 22, 2011 9:21 am

Post by deejunit » Sun Oct 16, 2011 5:54 am

ozone100 wrote:Is it possible to add a trailing slash at the end of URLs?
I am just curious, did you manage to solve this?

New member

Posts

Joined
Sat Jul 21, 2007 5:40 am

Post by shopfair » Thu Oct 20, 2011 2:43 pm

I would also love to know if there's a "fix" to add a trailing slash.

regardless of anyone's opinion whether it makes a difference or not !!!

Please comment on our online Shop http://www.suncig.com.au/


User avatar
New member

Posts

Joined
Tue Jun 07, 2011 12:08 am

Post by ozone100 » Fri Nov 04, 2011 4:24 am

This issue is critical to SEO especially with the recent Google Panda updates. Having duplicate URLs puts your website at risk of the Google Panda penalty and can result in significant traffic loss.

If anyone could shed some light on how to modify htaccess to remove/add trailing slashes it would be greatly appreciated.

New member

Posts

Joined
Fri Apr 22, 2011 9:21 am

Post by loki_racer » Fri Jan 20, 2012 11:34 pm

This is more than a .htaccess issue. You will need to modify OpenCart to generate all links with a trailing slash as well as route them.

/catalog/controller/common/seo_url.php

Code: Select all

- return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
+ return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query . '/';
/catalog/controller/common/seo_url.php after line 10

Code: Select all

        if(substr($this->request->get['_route_'],-1) == '/') {
        	$this->request->get['_route_'] = substr($this->request->get['_route_'],0,-1);	
	}
This seems to add slashes to the product and category pages.

Newbie

Posts

Joined
Tue Dec 13, 2011 6:37 pm

Post by deanballard » Sat Jan 21, 2012 12:22 am

So to do this do I replace

Code: Select all

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
In the seo_url.php with

Code: Select all

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query . '/';
Then add

Code: Select all

        if(substr($this->request->get['_route_'],-1) == '/') {
           $this->request->get['_route_'] = substr($this->request->get['_route_'],0,-1);   
   }
On line 11?

Thanks,

Dean

Newbie

Posts

Joined
Tue Jan 17, 2012 7:52 pm

Post by loki_racer » Sat Jan 21, 2012 1:21 am

Yes. However, please don't do this on a live site. I am currently testing it in a development environment, as you should as well.

Newbie

Posts

Joined
Tue Dec 13, 2011 6:37 pm

Post by loki_racer » Mon Feb 06, 2012 12:34 am

To have all URL's be built with the trailing slash, please modify this as well

Replace:

Code: Select all

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
with:

Code: Select all

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . '/' . $query;

Newbie

Posts

Joined
Tue Dec 13, 2011 6:37 pm

Post by deejunit » Tue Feb 28, 2012 4:31 am

loki_racer wrote:This is more than a .htaccess issue. You will need to modify OpenCart to generate all links with a trailing slash as well as route them.

/catalog/controller/common/seo_url.php

Code: Select all

- return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
+ return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query . '/';
/catalog/controller/common/seo_url.php after line 10

Code: Select all

        if(substr($this->request->get['_route_'],-1) == '/') {
        	$this->request->get['_route_'] = substr($this->request->get['_route_'],0,-1);	
	}
This seems to add slashes to the product and category pages.
Thanks :)

New member

Posts

Joined
Sat Jul 21, 2007 5:40 am

Post by JackNight » Mon May 07, 2012 11:29 pm

Code: Select all

+ return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query . '/';
as a result I've got double slash for homepage url... :((
like this - http://shop.com// - < double slash
somebody can help me?

Newbie

Posts

Joined
Mon May 07, 2012 5:25 pm

Post by Nyrk0 » Thu Oct 25, 2012 10:55 am

This code add Trailing Slash at the end of SEO category and manufacturers directory-URLs only, not at the end of product page-URLs.

file: seo_url.php

line 76:

Code: Select all

$url .= '/' . $query->row['keyword'];
if ($key == 'manufacturer_id') { $url .= '/'; }
line 85:

Code: Select all

if ($query->num_rows) {
// $url .= '/' . $query->row['keyword'];
$url .= '/' . $query->row['keyword'] . '/';
}
line 113:

Code: Select all

// return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
$pathurl = str_replace('/index.php', '', $url_data['path']) . $url;
return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('//','/',$pathurl) . $query;
This works for me at http://www.globalmac.cl and can be done with vqmod :)

New member

Posts

Joined
Tue Sep 18, 2012 4:46 am

Post by SupraTwinTurbo » Sun Feb 24, 2013 5:56 pm

Has anyone figured out how to successfully add a trailing slash to the end of all SEOed pages (including product pages)? If so can you share the vqmod or code?

User avatar
New member

Posts

Joined
Thu Mar 24, 2011 12:43 pm
Location - NYC, NY USA

Post by yowchuan » Sat Mar 02, 2013 2:17 pm

Yeah man, I think this is one very important aesthetic aspect. It's like organizing your stuff on your desktop, everyone has a different way of doing it. It would be great if there's a easy way to add/remove trailing slashes on pages.

And there's an interesting discussion on trailing slashes here:
http://stackoverflow.com/questions/5948 ... -preferred

New member

Posts

Joined
Wed Feb 06, 2013 2:39 am
Who is online

Users browsing this forum: No registered users and 43 guests