Hello. I just posted a new "tutorial" about having "truly" SEO urls |
03-23-2016, 08:15 AM
(This post was last modified: 03-23-2016, 08:15 AM by Avenirer. Edit Reason: forgot to put the url... :)) )
Hello, CI community.
A lot of people asked about having SEO friendly URLs, and even though we can set translate_uri_dashes to TRUE inside the routes.php, we still have a problem with "duplicate content", as urls with underscores still work at the same time as the urls with dashes. This tutorial, is not really a tutorial, but is a good way to invite people to look inside the CodeIgniter code. If anyone has another solution, or if my solution is bad, please do tell me. Thank you. http://avenir.ro/how-to-make-truly-seo-u...core-urls/ Website: http://avenir.ro
Hi,
Interesting post - thanks. As I was reading it and you got to the bit about Quote:Then how do save ourselves from this SEO Armageddon? Well… Let us take a look at the Router.php inside the system/core. I though, "oh no, don't start fiddling about with the core". And then as I pondered through the code, still muttering to myself I got to: Quote:So, this is the culprit… But what now? Should we simply modify it? No… NEVER MODIFY THE SYSTEM FILES IN CODEIGNITER! That made me chuckle. A very well written post. I might give it a test with a small site sometime but doesn't having a canonical link on all your pages sort out all that SEO 'repeated content' problems anyway? Best wishes, Paul.
Hello,
Thank you for sharing , In the code has some problems when applied . Eg: base ( ' auth / edit_user / 1 ' ) --- > real url : localhost / authedit-user not "/" and parameter I think you should add a few lines of code : line 54 : Code: $url .= str_replace( '_' , '-' , $segments[0] . '/'); and Code: if (count($segments) > 2)
I never like doing something with PHP that the server can do better. If you are on an Apache server with mod_rewrite enabled:
Code: RewriteRule ^(.*)_(.*)$ $1-$2 [N,E=redirect:true] By doing this you will just have a single redirect at the server level, and if CodeIgniter can't route to the URL it will just 404. No core extensions required. Credit: https://www.geoffhayward.eu/2014/04/char...od-rewrite (03-23-2016, 08:32 PM)nguyenanhnhan Wrote: Hello, Thank you for looking at it. I just changed it. I usually do tutorials on fresh installs and I didn't think of testing it on something else than the Welcome controller ![]() Website: http://avenir.ro
(03-23-2016, 09:46 PM)skunkbad Wrote: I never like doing something with PHP that the server can do better. If you are on an Apache server with mod_rewrite enabled: That is an interesting idea. Does it also work on the second segment of a url? Website: http://avenir.ro
(03-23-2016, 06:21 PM)PaulD Wrote: Hi, The most important part in learning is the road ![]() Website: http://avenir.ro
|
Welcome Guest, Not a member yet? Register Sign In |