php mvc和.htaccess url重写

我是一个新的程序员,目前正在学习 PHP的MVC.我从头开始建立一个框架/ MVC系统……现在我面临的问题的.htaccess.

example.com = localhost // unable to post question for localhost link

我的应用程序的URL是这样的…

        http://example.com/mvc/index.PHP?go=test //test is a controller's name

通过从.htaccess中的帮助下,我清理的URL ….

        http://example.com/mvc/test

如果控制器不存在,它显示一个错误视图,其中包含一些错误消息.
    

        http://example.com/mvc/doesnotexists

 但是,如果我把“/”(正斜杠)的网址…

        http://example.com/mvc/test/

 它显示错误,但不加载任何CSS或JS文件.

我也包含在URL控制器方法

        http://example.com/mvc/test/viewresult

 如果在控制器显示错误消息,没有发现匹配的方法,它显示但同样的问题…没有CSS也不js的.

我已经完全加载CSS和JS如果我经历完整的URL

        http://example.com/mvc/index.PHP?go=doesnotexists/

  等等

我尝试了好几种的.htaccess规则,但无法得到它的工作.请帮忙在此先感谢.我currrent的.htaccess代码

<IfModule mod_rewrite.c>  

    # Turn on 
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l

    #RewriteCond %{REQUEST_URI} !^/assets/
    #RewriteCond $1 !^(favicon\.ico|favicon\.png|media|robots\.txt|crossdomain\.xml|.*\.css|.*\js)

    RewriteRule ^(.+)$index.PHP?go=$1 [QSA,L]

   # Generic 404 for anyplace on the site  
   # ...  

</IfModule>

解决方法

css和js的最佳解决方案是使用完整路径:

http://example.com/mvc/assets/style.css

http://cdn.example.com/style.css

并重写

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.PHP?go=$1

如果你的’test’是你的控制器,’param’是’test’控制器的动作
您可以使用

http://example.com/mvc/test/param

$_GET [‘go’]将是’test / param’你需要爆炸才能获得’param’动作

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...