-3

How to use url rewrite with parameters

example.com/news.php?id=1 to example.com/news/1

And the value of number will change dynamically.

Edwin Thomas
  • 1,186
  • 2
  • 18
  • 31

2 Answers2

1

Yes, there are many similar questions. But here is how to do it.

RewriteEngine On
RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [NC,L]

You should have mod_rewrite enabled in your server.

Nimeshka Srimal
  • 8,012
  • 5
  • 42
  • 57
1
RewriteEngine On
RewriteRule ^news/([0-9]*)$ /news.php?id=$1 [L]
robenrajan
  • 355
  • 1
  • 8
  • 2
    Note that this rule will also match `example.com/news/` and will send that to `example.com/news.php?id=` – Scopey Aug 22 '14 at 04:29