Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 608
Greg Alexander Avatar asked Dec 10 '25 09:12

Greg Alexander


2 Answers

RewriteEngine on
RewriteRule ^(\d+)/(\w+).html$ index.php?id=$1&title=$2
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)/(.*)\.html$ index.php?id=$1&title=$2                   
like image 32
Sujit Agarwal Avatar answered Dec 12 '25 21:12

Sujit Agarwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!