Is it possible to dynamically redirect URL using htaccess?

Is there any way to dynamically redirect URLs. For example, I want to redirect any URL from https://example.com/NNNNN to https://examplecom/?p=NNNNN.

Where NNNNN could be any possible numbers.

For example: https://example.com/1796 should redirect to https://example.com/?p=1796.

1 Answer
1

StackOverflow has already an answer for your question: https://stackoverflow.com/questions/2551553/htaccess-redirecting-dynamic-url

I guess that this should do the trick:

RewriteRule ^(\d+)$ /?p=$1 [R=302,L]

Leave a Comment