2

My project is almost complete so I cannot make changes in url throughout project.whenever I use redirect like

redirect('welcome?loggedout=true', 'refresh');

Page get redirected to

welcome?loggedout=true.php

I have added URL suffix

$config['url_suffix'] = '.php';

But can I use it as optional and url remains normal with extension until I want to customise a link with .php.

5
  • After all the research,i found that there is only one way to achieve this. Use route for pages where you want extension and leave url_suffix empty. Commented Jun 8, 2015 at 9:38
  • you should make $config['url_suffix'] = ''; or try it using simple php redirect header("Location: example.com/welcome.php?loggedout=true"); Commented Jun 8, 2015 at 9:55
  • Not clear what you are asking Commented Jun 10, 2015 at 12:39
  • @Lupin - I m asking how to make URL suffix optional. Commented Jun 11, 2015 at 4:12
  • when will you use it and when not? Commented Jun 13, 2015 at 17:30

2 Answers 2

0

In order to use Query String URL’s, edit config.php which is located in application/config. Set enable_query_strings to TRUE and define controller and function trigger.

$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';

Output

enter image description here

Go through this source

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

Comments

0

Just to complement and update, you can use suffixes for some URLs only and not all your project - using routes from codeigniter. OP mentions this on his comment but provided no examples.

Here's a example: http://antsplace.co.uk/url-suffix-in-codeigniter/

I did not do the same thing. In my case, I just needed suffixes for .xml pages So I only put, on routes.php :

$route['newsfeeds/(:any)\.xml'] = 'newsfeeds/index/$1';

And created a Newsfeeds controller and index function to handle. That's it. That way only URLs with /newsfeeds on segment 1 will allways apply/accept .xml suffix

index controller function is likely many others:

public function index()
    {
        $this->load->helper('xml');
        $this->load->view('xml_view');
    }

Don't forget to call header("Content-Type: application/rss+xml; charset=utf-8"); in your site header to properly render xml to this views or you can do this with codeigniter inbuilt function as described in: https://stackoverflow.com/a/10361155/2387741

And at last this xml helper (docs here) help you translate some characters that need correct formatting on xml to work properly.

I guess this is it. Best regards.

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.