I am using Codeigniter (for the first time). I want to have the URL of a page “web-design”, so it could be accessed like /web-design . I know it’s impossible to make a class name with “-“, so I have tried to make it possible using .htaccess, like this:
RewriteEngine on
RewriteRule ^web-design$ index.php/webdesign [L]
RewriteCond $1 !^(index\.php|images|robots\.txt|assets)
RewriteRule ^(.*)$ index.php/$1
but it’s not working. It’s giving me 404 error.
How can I make it work? Thanks!
You should use routing in CI instead! That’s why they made it.
This is actually pretty simple.
In
application/config/routes.php add the following to the $route array:Then you can create a controller called
Webdesign; problem solved – the right way.No need to extend anything or create other rewrite rules.