• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fully qualified SEO URLs, how to be allowed to use them?

#11
[eluser]saijin[/eluser]
[quote author="ray73864" date="1227275388"]negatory, you can't have a dash in the controller name, i can't really see why you would need to have it either.[/quote]

for SEO Friendly URL..

#12
[eluser]johnwbaxter[/eluser]
Google have said that they treat underscores in urls exactly the same as a dash in a url. They said this some time ago (i think it's on Matt Cutts blog).

So there you go, problem solved.

#13
[eluser]Colin Williams[/eluser]
Meh.. Unfortunate you make that point, audiopleb. I don't know why CI doesn't just attempt to map dashed controller/function URI parameters to underscored class and class member function names. Well, actually, I do have a hunch why this isn't done, but it still seems slightly ridiculous.

Three simple solutions remain. 1.) Abandon the dashes and adopt underscores, like audiopleb suggests. 2.) Override the necessary Router class member function(s) to make CI think of dashes as underscores. 3.) Lose the two-word URI param altogether. Just name the class "Outsourcing." This last option is my favorite Smile

#14
[eluser]Joshua Logsdon[/eluser]
So far, so good with overriding the Router library's _set_request() method to change dashes found in the first two segments to underscores.

Attached is the MY_Router.php file (inside the .zip) that I'm using in my application/libraries/ directory and here is the addition to the method mentioned above:

Code:
for ( $i = 0; $i < 2; $i++ )
{
    if ( isset($segments[ $i ]) && strpos($segments[ $i ], '-') !== FALSE )
    {
        $segments[ $i ] = str_replace('-', '_', $segments[ $i ]);
    }
}

#15
[eluser]b3nst3wart[/eluser]
Try my solution posted in a similar thread here:

http://ellislab.com/forums/viewreply/644012/

#16
[eluser]Eric Cope[/eluser]
switch to underscores.

#17
[eluser]jv2222[/eluser]
[quote author="Joshua Logsdon" date="1250163628"]So far, so good with overriding the Router library's _set_request() method to change dashes found in the first two segments to underscores.

Attached is the MY_Router.php file (inside the .zip) that I'm using in my application/libraries/ directory and here is the addition to the method mentioned above:

Code:
for ( $i = 0; $i < 2; $i++ )
{
    if ( isset($segments[ $i ]) && strpos($segments[ $i ], '-') !== FALSE )
    {
        $segments[ $i ] = str_replace('-', '_', $segments[ $i ]);
    }
}
[/quote]

Kudos and thanks for the MY_Router.php works perfectly! Smile

#18
[eluser]dynZack[/eluser]
Extend the Router class with the following MY_Router :

Code:
&lt;?php
class MY_Router extends CI_Router
{
function _set_request($segments = array()) {
  parent::_set_request(str_replace('-', '_', $segments));
}
}

#19
[eluser]mteejay[/eluser]
[quote author="Joshua Logsdon" date="1250163628"]So far, so good with overriding the Router library's _set_request() method to change dashes found in the first two segments to underscores.

Attached is the MY_Router.php file (inside the .zip) that I'm using in my application/libraries/ directory and here is the addition to the method mentioned above:

Code:
for ( $i = 0; $i < 2; $i++ )
{
    if ( isset($segments[ $i ]) && strpos($segments[ $i ], '-') !== FALSE )
    {
        $segments[ $i ] = str_replace('-', '_', $segments[ $i ]);
    }
}
[/quote]

Is this solution still working with the latest release of CI (2.0.2)?

#20
[eluser]Joshua Logsdon[/eluser]
Got questions from a couple people recently. Keep in mind that solution is almost 2 years old now!

The idea was how can I get around managing routes.php config when I'm switching around lots of controllers, etc. So overriding the router may be overkill for most situations and stick to just managing routes.php like mentioned here:
http://ellislab.com/forums/viewthread/187580/#889493

In Router.php's _validate_request method, I change '-' to '_' when $segments[0] is checked. In another thread there is a good tip to do this for the set_class and set_method methods and so I got rid of changing the _set_request method with that tip.

Attached is the MY_Router I'm using in CI 2.0.2, now in \application\core\


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.