Hello,
I’ve been using CI for a while and love it. However, many clients are asking for hyphens in URLs instead of underscores which helps with SEO. I partner with two SEO firms, both of which confirm while having hyphens over underscores is not monumental it does help.
As you know, CI controllers must use underscores as hyphens will not work. I have a mod_rewrite in place that ALMOST works in getting everything converted. Yet the first hyphen in a URL (for the class name) doesn’t work. The mod_rewrite looks like this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ([^-]*)-([^-]*)-([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*)-?([^-]*) $1_$2_$3_$4_$5_$6_$7_$8_$9 [L]
RewriteRule ^(.*?)__+(.*) $1$2 [L]
RewriteCond $1 !^(index\.php|css|emails|favicon\.php|flash|img|p\.php|public|scripts|robots\.txt|tmp)
RewriteRule ^(.*)$ index.php?$1 [L]
The issue is that:
/class-name/
throws a 404 while:
/class-name/function-name/
does not. So even though a class name works fine when the URL contains children segments, it does not when it’s loaded on its own.
If anyone knows how to get CI controllers to behave when hyphens are used instead of underscores, I would GREATLY appreciate the advice.
Thanks in advance for your time.
