D
D
DarkUser13372020-03-19 02:31:16
Web development
DarkUser1337, 2020-03-19 02:31:16

How to modify the URL?

I must say right away that I am new to web development.
I have a link that looks like this: example.com/user.php?id=1
How do I replace it with example.com/user/1 ? And how then can I contact this: example.com/user/1/profile , naturally, without creating a folder for each user?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2020-03-19
@shambler81

First part of the question

RewriteCond %{QUERY_STRING} (^|&)id\=(.+)($|&)
RewriteRule ^user\.php$ /user/%2? [L,R=301]

The second part is created by your CNC

A
AUser0, 2020-03-19
@AUser0

On the Web server side - use RewriteRule in .htaccess, that's what .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question