简体   繁体   中英

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 ie: 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

convert a .php to html for a speific url ie: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM