最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Is it possible to dynamically redirect URL using htaccess?

matteradmin8PV0评论

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

Where NNNNN could be any possible numbers.

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

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

Where NNNNN could be any possible numbers.

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

Share Improve this question edited Apr 1, 2019 at 17:11 MrWhite 3,8911 gold badge20 silver badges23 bronze badges asked Apr 1, 2019 at 5:10 Avinash PatelAvinash Patel 398 bronze badges 1
  • Redirect or rewrite? – Krzysiek Dróżdż Commented Apr 1, 2019 at 6:37
Add a comment  | 

1 Answer 1

Reset to default 2

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

I guess that this should do the trick:

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

comment list (0)

  1. No comments so far