Greg Alexander
Greg Alexander

Reputation: 1222

How to rewrite .php to .html with mod_rewrite rules

Prolly an easy one.. I am trying to study up on mod_rewrite and ran into an issue

Here is my url

example.com/index.php?id=1&title=some_title

I want the page to be able to take

example.com/1/some_title.html

How would I do that?

Upvotes: 2

Views: 1074

Answers (2)

Sujit Agarwal
Sujit Agarwal

Reputation: 12518

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)/(.*)\.html$ index.php?id=$1&title=$2                   

Upvotes: 2

user142162
user142162

Reputation:

RewriteEngine on
RewriteRule ^(\d+)/(\w+).html$ index.php?id=$1&title=$2

Upvotes: 7

Related Questions