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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2007, 05:41 PM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 101
Default SEO friendly URL's on Zend Framework

Hello,

I am very concern about SEO things for some websites and i am wondering what can do ZF for us. This is in fact the main reason for which i didn't switched to ZF MVC totally... Because i didn't found out a workaround for Controller side...

One problem i consider important is URL format.

Sample: Rather than focusing over URL format as: /news/view/73
....
I personally prefer to use a totally different format as: /This-is-the-news-title-19_73

where:
* "This-is-the-news-title" is news title
* 19 is page identifier (each page having his own id); i think standard Zf format (controller-view) is not always the best approach
* 73 is news identifier...

Why ? Because:
* is not a good idea to use a file into a directory, a file directly into root is ranked better by SE than one file under /onedire/subdir/subdir/filename
* using a filename format URL friendly helps on SE rankings: "This-is-the-news-title"
* because using "news" word means "news" is getting SEO exposure, and i don't want this, instead a number is filtered by SE so doesn't get exposure

So, i am wondering if there are any possibilities to work with controller side this way, more SEO friendly... Because standard controller doesn't help much...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-27-2007, 12:29 AM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 122
Default

simple just create a custom router
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-27-2007, 07:59 AM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 101
Default

You mean a implementation of:

Zend_Controller_Router_Route_Interface ?

I was able to partially solve problem by adding:

//added...
$router = $frontController->getRouter(); // returns a rewrite router by default
$router->removeDefaultRoutes();

$router->addRoute(
'user',
new Zend_Controller_Router_Route(':anytext_:controller _:action')
);

Format is still not what i wanted but anyway... More closer...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-27-2007, 11:06 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 122
Default

Inorder to get the format you want you will probably have to use some regex expressions to parse out the path and create a route
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-31-2007, 04:46 PM
Junior Member
 
Join Date: Mar 2007
Posts: 1
Default

Did you ever get this working? I'm starting on a new project next week that will need to do someting similar to this. Any code you could share would be appreciated...

-Chris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-31-2007, 05:55 PM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 101
Default

On index.php

PHP Code:
// load configuration
$config = new Zend_Config_Ini('./application/config.ini''general');
$registry Zend_Registry::getInstance();
$registry->set('config'$config);

// setup router
$router $frontController->getRouter();
$router->removeDefaultRoutes();
$router->addConfig($config'routes'); 

On config.ini

[general]

routes.index.route = ":seo_:controller_:action"
routes.index.defaults.controller = index
routes.index.defaults.action = index

I am not totally sure is 100% fine didn't tested very much... I tested constructing directly route not from .ini

Last edited by SpotSec : 05-02-2007 at 06:01 AM. Reason: Added php tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-15-2007, 06:37 AM
Junior Member
 
Join Date: Feb 2007
Posts: 26
Default

Quote:
Originally Posted by SpotSec View Post
simple just create a custom router
I'm new to this custom router thing and since documentation/end-user/core/en/zend.controller.router.html confuses me, could you give me some links where I can get an enlightment

Thanks!

Last edited by Tommy1402 : 06-15-2007 at 06:40 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 06-16-2007, 06:32 AM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 122
Default

Well, I'm not sure there are any links right now that talk about writing your own routers, but if you are going down this path, I'm sure there are a few people lurking around this forum that can help you out. There are several other knowledgeable people in the irc channel if you want to chat.
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
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 01:16 AM.