Welcome Guest, Not a member yet? Register   Sign In
Fully qualified SEO URLs, how to be allowed to use them?
#1

[eluser]Zarkow[/eluser]
I'm very new to CI so bare with me, but I have been reading all the docs and this forum but one thing, which might be trivial for some but of high value to us, is the ability to have fully qualified and optimized URLs.

This for example means that http://example.com/outsourcing-services/ is a better URL than just /services/, but php doesn't allow the object names to contain '-'...and naming the controller file outsourcing-services.php while having the class be named 'Outsourceservices' doesn't work either since then CI returns 404, file not found...

So how does one go about to have urls containing dashes? At highest level already. While still keeping the source neatly divided into the different controllers for different areas if wanted.

I'm sure it's something easy I missed, but too much reading turns one blind sometimes.

Thanks in advance.
#2

[eluser]Yash[/eluser]
Controller cannot have dash and all..No full proof solution yet.

you are allowed to used dash in next url segments.
#3

[eluser]wiredesignz[/eluser]
There is a little function in the CI url_helper named url_title() which may help here.

Example:
Code:
url_title('some-url-string', 'underscore'); // produces 'some_url_string'
The default option is 'dash' and will convert in the opposite direction if the second variable is omitted.
#4

[eluser]Zarkow[/eluser]
Yash: Thanks for your fast response...I suppose one way would be to use mod_rewrite to splice a dash-one-dir-url to several sections...which kinda negates the point of not going from that to a normal file+parameter style right away...owell. Big Grin

[quote author="wiredesignz" date="1216744916"]There is a little function in the CI url_helper named url_title() which may help here.

Example:
Code:
url_title('some-url-string', 'underscore'); // produces 'some_url_string'
The default option is 'dash' and will convert in the opposite direction if the second variable is omitted.[/quote]

Not sure how that would help out in this case. That is the inverted function, to create a dashed safe url, not handling a top-level dashed url.
#5

[eluser]wiredesignz[/eluser]
Yes, sorry I use this method with _remap and a default_controller, it may not be applicable to you.

However, You could try str_replace() or preg_replace() in routes.php
#6

[eluser]Yash[/eluser]
yes wiredesignz that's my point.

anyways by default its not possible we need some hack ..
#7

[eluser]Zarkow[/eluser]
[quote author="wiredesignz" date="1216746875"]Yes, sorry I use this method with _remap and a default_controller, it may not be applicable to you.

However, You could try str_replace() or preg_replace() in routes.php[/quote]

Well, yes, doing it hard in routing works...but it's not very pretty.

Example:
$route['very-long-test'] = "welcome/testing";

Then I know atleast. Big Grin
#8

[eluser]meigwilym[/eluser]
You could try a regex in the routing. I'm not an expert on regex, but something like this

Code:
$route['([a-z]+)-([a-z]+)'] = "$1$2";

This isn't tested, so I'm unsure if it would work as intended. Maybe someone with more regex kung fu than I will help out.

Best,

Mei
#9

[eluser]saijin[/eluser]
[quote author="Zarkow" date="1216743980"]I'm very new to CI so bare with me, but I have been reading all the docs and this forum but one thing, which might be trivial for some but of high value to us, is the ability to have fully qualified and optimized URLs.

This for example means that http://example.com/outsourcing-services/ is a better URL than just /services/, but php doesn't allow the object names to contain '-'...and naming the controller file outsourcing-services.php while having the class be named 'Outsourceservices' doesn't work either since then CI returns 404, file not found...

So how does one go about to have urls containing dashes? At highest level already. While still keeping the source neatly divided into the different controllers for different areas if wanted.

I'm sure it's something easy I missed, but too much reading turns one blind sometimes.

Thanks in advance.[/quote]

How is it? Did anyone solved the issue?
#10

[eluser]ray73864[/eluser]
negatory, you can't have a dash in the controller name, i can't really see why you would need to have it either.




Theme © iAndrew 2016 - Forum software by © MyBB