Answer the question
In order to leave comments, you need to log in
How to replace url in .htaccess and get variable with GET request?
Hello colleagues!
There is an interesting problem for me, but I am not at all familiar with .htaccess, please help me figure it out ...
The task is this:
There is an index.php page
How to get a variable in such site.ru/index.php?id=1 it’s clear how)))
and here is how to replace site.ru/index.php?id=1 with site.ru/user1 so that the script below, user 1 value accepts 1 as id value
<?php
if ($_GET['id'] = 1) {
$id = 12346;
}
if ($_GET['id'] = 2) {
$id = 12347;
}
if ($_GET['id'] = 3) {
$id = 12348;
}
echo $id;
?>
Answer the question
In order to leave comments, you need to log in
RewriteEngine On
RewriteRule ^user([0-9]+)$ /index.php?id=$1 [L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question