How to rewrite .php to .html with mod_rewrite rules

♀尐吖头ヾ 提交于 2020-01-15 08:20:10

问题


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?


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/6162447/how-to-rewrite-php-to-html-with-mod-rewrite-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!