douou1872 2016-08-11 02:34
浏览 58
已采纳

重写规则 - MVC - OOP

Hi guys i'm trying to apply a rule on my htaccess :

I made a MVC framework (OOP) in php .

RewriteRule ^([A-Za-z]+)/([A-Za-z]+)/([0-9]+)$ ?module=$1&action=$2&id=$3 [L,QSA]
RewriteRule ^([a-z]+)/([a-zA-Z]+)$ ?module=$1&action=$2 [L,QSA]

Where module is the name of the controller and action is the function of the controller.

Example of url : http://mywebsite.com/ads/sell

How can i write http://mywebsite.com/contact instead of http://mywebsite.com/page/contact with a rule in my htaccess.

I dont have a router class

  • 写回答

1条回答 默认 最新

  • douzhan5058 2016-08-11 03:09
    关注

    Try this one

    RewriteRule ^([a-zA-Z]+)$ ?module=page&action=$1 [L]
    

    comment if have any error issue

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部