Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is some pseudo code and a few points in the right direction to get you started. </p> <p>Firstly, you will need to remove the index.php from your urls. There must be hundreds of questions on here already answering this part of the question, so I will leave this part up to you.</p> <p>As many have commented, there is no way to achieve this url structure out the box, and it will require quite a lot of code to get working. The way I would implement this particular setup would be to route all requests to a single controller, and handle custom routing within that controller. </p> <p>To do this add a route to the bottom of the <code>routes.php</code> as a catch all. Routes for other controllers (news, events, etc) can then be added above this one. Here is an example routes.php to get you started.</p> <p><strong>config/routes.php</strong></p> <pre><code>// Other routes go up here // Catch all route $route['(:any)'] = 'page/view'; // Home page route $route['default_controller'] = "page/index"; </code></pre> <p>You could then create a <code>view</code> function in <code>controllers/page.php</code> that will check the url (using codeigniters url helper), and load the correct view corresponding to that url.</p> <p><strong>controllers/page.php</strong></p> <pre><code>class Page extends CI_Controller { public function index() { // Do all code for your home page in here } public function view() { // Retrive the url string $url = $this-&gt;uri-&gt;uri_string(); // Check if the corresponding view file exists if (file_exists(APPPATH.'views/'.$url.'/index.php')){ // Load the view $this-&gt;load-&gt;view($url.'/index'); } else { show_404(); } } } </code></pre> <p>Say for example, a user went to <code>http://yoursite.com/CI/about-us</code>, the page controllers view function would take the string <code>about-us</code> from the url and set it as the $url variable, and then search your file structure to check if the corresponding view file exists <code>/application/views/about-us/index.php</code>. If it does, it will then load that view file, if it doesn't it will redirect to a 404. </p> <p>The above is all pseudo code typed from memory, so it probably won't work straight off, but hopefully give you a clue as to how to achieve your desired result.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload