I
I
Ivan2021-10-31 14:13:19
htaccess
Ivan, 2021-10-31 14:13:19

How to properly configure .htaccess with redirect with id?

Explain page:

domen.ru/page?id=123 должна перейти в domen.ru/page123


It turns out to be done with:
RewriteRule ^page/(.*)?$ page.php?id=$1 [L]
But then the page will be domen.ru/page/123, i.e. with a slash before id.
If you do
RewriteRule ^page(.*)?$ page.php?id=$1 [L]
that, it stops working altogether.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2021-10-31
@youmixx

I tried for a long time, asked a question - I immediately found the answer.
RewriteRule ^page([0-9]+)?$ page.php?id=$1 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question