Digital site
Digital site

Reputation: 4447

mod_rewrite for specific url only

I'm into rewriting a url in different ways. I mean I want to know how to use mod_rewrite so I can do the following:

1- convert a .php to html for a speific url i.e: from www.mydomain.com/news.php to www.mydomain.com/news.html

I found some interesting codes, but not sure which one works without any errors...

some of what I found:

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

2- convert any sub url of that news.php file to

news.php?do=news&id=24455

so the topics or threads show like this without slashes /

I find the 2nd question a lot difficult, but sure there must be a solution for that.

any idea how to get both questions done for a specific url like what I stated above...!!

Thanks

Upvotes: 0

Views: 84

Answers (1)

zerkms
zerkms

Reputation: 254944

convert a .php to html for a speific url i.e: from www.mydomain.com/news.php to www.mydomain.com/news.html

RewriteRule ^news\.html$ /news.php

Guess for the second (assuming you want to rewrite /news/foo.html urls):

RewriteRule ^news/(.*)\.html$ /news.php?id=$1

Upvotes: 1

Related Questions