Php 使用控制器时Smarty美化url
我发现这篇文章最符合我的需要,我只是没能完全满足我的需要。 我有如下url:Php 使用控制器时Smarty美化url,php,.htaccess,Php,.htaccess,我发现这篇文章最符合我的需要,我只是没能完全满足我的需要。 我有如下url: mysite.de/index.php?cl=services 我想要这样的东西: mysite.de/services 最简单的方法是什么 RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?p=profile&id=$1 应致力于: www.domain.com/index.php?p=profile&id=20 到 就你的
mysite.de/index.php?cl=services
我想要这样的东西:
mysite.de/services
最简单的方法是什么
RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?p=profile&id=$1
应致力于:
www.domain.com/index.php?p=profile&id=20
到
就你的例子来说
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^services$ /index.php?cl=services [L]
如果需要多个URL,则需要多个
RewriteRule
s。或者您可以将它们组合在一起(即,RewriteRule^(services | contact)$/index.php?cl=$1
),但多个规则更易于阅读和维护。当您说您可以“让它满足您的需要,您的需要是什么?”?什么是cl=
,是页面名称还是ID,参数值中可能包含哪些字符,等等。当有人要求澄清时,请编辑您的帖子,尽量不要用答案进行评论。欢迎来到Stack Overflow。我已经解决了一些英语问题。我还通过添加4个空格来标记URL。如果你发布你当前的努力,它将帮助其他人更快地帮助你。到目前为止,你尝试了什么?它实现了什么。当我想重新路由每个呼叫时,它会是什么样子?不仅仅与一个特定页面相关
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^services$ /index.php?cl=services [L]