-2

I read all the topic about the next question but i cant fin solution.. On my CodeIgniter project, i have this link to see user profil:

user/profil?id=1

But i want

user/profil/1

And i cant find solution.. Where put the code ? Do i need ROUTE or .htaccess ? My htacess look like this.

#   Empêche la visualisation de l'arborescence, n'a rien à voir avec le masquage du « index.php ».
Options -Indexes

#   Active le module de réécriture d'URL.
RewriteEngine on

#
#   Fixe les règles de réécriture d'URL. Ici, nous utilisons une liste blanche.
#

#   Toutes les URL qui ne correspondent pas à ces masques sont réécrites.
RewriteCond $1 !^(index\.php|assets/|robots\.txt|uploads)

#   Toutes les autres URL vont être redirigées vers le fichier index.php.
RewriteRule ^(.*)$ index.php/$1 [L]

My profil controllers:

public function profil()
{
    // Récupération de l'ID dans l'url
    $this->data['id'] = $this->input->get('id', TRUE);

// Statistiques du profil
$this->data['countReview'] = $this->review_model->countReview($this->data['id']);

// Chargement du profil de l'utilisateur
if (ctype_digit($this->data['id'])) {
    if ($this->user_model->getUser($this->data['id'])) {
        $this->data['users'] = $this->user_model->getUser($this->data['id']);
        $this->data['reviewsNext'] = $this->review_model->getReviewsByUser_Next($this->data['id']);
        $this->data['reviewsPrevious'] = $this->review_model->getReviewsByUser_Previous($this->data['id']);
    } else {
        $this->session->set_flashdata('error', 'Utilisateur introuvable.');
    }
} else {
    $this->data['error_report'][] = "Utilisateur introuvable.";
}

$this->load->view('template/header');
$this->load->view('template/menu');
$this->load->view('user/profil', $this->data);
$this->load->view('template/footer');

}

Thanks for your answer.

Haandler
  • 11
  • 3

1 Answers1

0
# Redirect profile.php?id=1 to profile/1
RewriteCond %{THE_REQUEST} \s/profile\.php\?id=([0-9]+)\s [NC]
RewriteRule ^/profile/%1? [R=301,L]
RewriteRule ^profile/([0-9]+)$ /profile.php?id=$1 [L]

Should work.