Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I combine routing and uri segments to put the user id in the url when on a specific user page?
    text
    copied!<p>I am trying to attach the user id to the url when viewing their page or the same thing when viewing another users page. I am getting this error <code>Unable to load the requested file: account/profile/218.php</code> With this code:</p> <p>//Routes.php</p> <pre><code>$route['default_controller'] = "home"; $route['404_override'] = ''; $route['profile/:num'] = "account/profile"; //I've also tried doing $route['profile/([a-z]+)/(\d+)'] = "profile/$1/id_$2"; </code></pre> <p>//Controller without the uri segment which produces the above stated error:</p> <pre><code>public function profile() { $this-&gt;load-&gt;helper('date'); $this-&gt;load-&gt;library('session'); $session_id = $this-&gt;session-&gt;userdata['id']; $this-&gt;load-&gt;model('account_model'); $user = $this-&gt;account_model-&gt;user(); $data['user'] = $user; $data['profile_icon'] = 'profile'; $data['main_content'] = 'account/profile/'.$user['id']; $this-&gt;load-&gt;view('includes/templates/profile_template', $data); } </code></pre> <p>and when I use this:</p> <pre><code>public function profile() { $this-&gt;load-&gt;helper('date'); $this-&gt;load-&gt;library('session'); $session_id = $this-&gt;session-&gt;userdata['id']; $this-&gt;load-&gt;model('account_model'); $user = $this-&gt;account_model-&gt;user(); $data['user'] = $user; $user['id'] = $this-&gt;uri-&gt;segment(4); $data['profile_icon'] = 'profile'; $data['main_content'] = 'account/profile/'.$user['id']; $this-&gt;load-&gt;view('includes/templates/profile_template', $data); } </code></pre> <p>it produces this error:</p> <blockquote> <p>Unable to load the requested file: account/profile/.php</p> </blockquote> <p><em>*</em>*EDIT</p> <p>HTACCESS</p> <pre><code>Deny from all RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] </code></pre>
 

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