将网址从/example.php?id=1进行Mod重写的网址更改为/example/title-page [英] Mod-rewrite url from /example.php?id=1 to /example/title-of-page
问题描述
我有一个网站,生成的网址如下:
I have a website that generates urls like:
www.site.com/example.php?id=1
www.site.com/example.php?id=1
我希望该网址显示如下:
I would like that url to be displayed like:
www.site.com/example/the-title-of-the-page-whatever-it-may-
www.site.com/example/the-title-of-the-page-whatever-it-may-be
我可以在.htaccess中执行此操作吗,还是需要编辑php或其他内容?
Can I do this in .htaccess or do I need to edit the php or what?
要温柔些,请像个白痴一样对待我-我是这一切的新手:)
Be gentle, and treat me like an idiot please - I'm brand new to all this :)
推荐答案
将此用于您的htaccess:
Use this for your htaccess :
RewriteEngine开启
RewriteRule ^([^/] *).html $/example.php?id=$1 [L]
RewriteEngine On
RewriteRule ^([^/]*).html$ /example.php?id=$1 [L]
您的旧网址> example.com/example.php?id=1
将更改为> example.com/1.html
Your Old URL > example.com/example.php?id=1
Will be change to > example.com/1.html
使用id:
RewriteEngine开启
RewriteRule ^ id/([[^/] *).html $/example.php?id=$1 [L]
RewriteEngine On
RewriteRule ^id/([^/]*).html$ /example.php?id=$1 [L]
您的旧网址> example.com/example.php?id=1
将更改为> example.com/id/1.html
Your Old URL > example.com/example.php?id=1
Will be change to > example.com/id/1.html
希望对您有所帮助;)
这篇关于将网址从/example.php?id=1进行Mod重写的网址更改为/example/title-page的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!