Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2008, 08:16 PM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Default help with trailing slashes

Hi

I'm currently starting to work with zf, but I've a big problem, that needs to be solved before I go on.

zf does not care about the trailing slash in urls, but it is a no go, if you want to go for seo.

An example:

GET /index/action HTTP/1.1

is not the same as

GET /index/action/ HTTP/1.1

If you have not spotted the difference, one has a trailing forward slash ‘/’ in the URI and one does not. For one is requesting the content of object ‘action’ under directory ‘/index/’, and another one is requesting the content of the index file under directory ‘/index/action/’. Although many of us would usually ignore the trailing slash, and write out the URL without it, web servers usually will correct this behaviour by replying a 301 permanent redirect to an URL with the trailing slash, if ‘action’ is indeed a directory.

Here is a point out of “Quality Guidelines - Specific recommendations” by Google:

Don’t create multiple pages, subdomains, or domains with substantially duplicate content.

But that is done as zf doesn't care about it.

So is there a way to get zf only accept urls with a trailing slash and throw a 404 or 301 if it does not?

thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-11-2008, 06:08 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

This an issue of Canonical URLs: (SEO advice: url canonicalization).

You can get a long way by just ensuring that all your links use the trailing slash in your code (href's and the like).

To further correct this (such as when users link to you using URLs with out the trailing slash), play with your rewrite rules in .htaccess, to always add it the slash if it doesn't exist.
__________________
- xentek
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-12-2008, 08:48 PM
Junior Member
 
Join Date: Oct 2008
Posts: 1
Default

Hi xentek,

thank you for your answer!
I got the same problem having more problems with it
Quote:
Originally Posted by xentek View Post
You can get a long way by just ensuring that all your links use the trailing slash in your code (href's and the like).
That's what I want to do. As Zend Framework provides a great class / helper Zend_View_Helper_Url I want to use it.
Therefore I configured my route test: "/test/" and tried to insert it inside my template using $this->url(array(...), 'test').
Unfortunately the helper destroyed everything and added the link without trailing slash

As you can see, I failed ensuring that all my links use the trailing slash in my code. Any ideas?

Thanks in advance!
Philipp

edit: This issue is tracked in the Zend Issue Tracking System: [#ZF-3807] URL assembly should include a trailing slash - Zend Framework Issue Tracker. Please vote for it
Even when it's tracked there: Does anybody here know a workaround?

Last edited by Philipp : 10-12-2008 at 08:59 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:44 PM.