2

Couldn't find solutions for my question. Who uses CodeIgniter knows that all URL in this framework are constructed as:

site.com/controller/method/parameter...

Is there a way fro changing that into some other pattern as for excample:

site.com/controller-method-parameter.html

So in general is there a way to simple change / for any other such char as - and having those urls generated atomaticly using ie. url helper?

5
  • 1
    im not sure what you are looking for, but in codeigniter you have route concept - ellislab.com/codeigniter/user-guide/general/routing.html Commented Feb 2, 2014 at 8:36
  • You probably need to try .htaccess rewrite Commented Feb 2, 2014 at 8:41
  • All cool @Janith with routes, i'm getting the concept there. What i want to achieve is Your normal approach would be in controller like: $this->load->helper('url'); site_url('applicationform/apply'); And You would get url like: site.com/controller/method what i'm aiming for is still use site_url('applicationform/apply') but at the frontend having for excample site.com/applicationform-appy. Just replace / with - and still be able to use those helpers Commented Feb 2, 2014 at 8:59
  • you are trying to do some things which is not given in the user guide i think you have to use other options like htaccess is the only options Commented Feb 2, 2014 at 9:38
  • There is no configuration for urls "join" char? .htaccess isn't the way i would like to use in this case because of loss of some functionality of framework. Commented Feb 2, 2014 at 10:17

1 Answer 1

1

yes you can do that. use the Routes class, for example you have a controller named 'stories' and a method called 'story' that takes a parametre 'story id' and display the appropriate story, so in your routes config file put

$route['story-(:num)'] = 'stories/story/$1';   

that's it :)

for more information take a look here https://codeigniter.com/user_guide/general/routing.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.