无法为MVC项目重写url

时间:2012-11-15 08:24:04

标签: php apache .htaccess url-rewriting

我被困在这里我已经尝试了谷歌搜索但找不到解决方案

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^index\.php|style.css|img\.png$ - [L]
   # RewriteRule .* index.php [L]
    RewriteRule ^(.*)$ index.php?params=$1 [NC]

当我点击网址http://localhost/moviestock/home/index print_r($_GET)时,我得到的输出Array ( )表示$_GET == array(),但我希望$ _GET像这样$_GET == array('controler'=> 'home', 'action' => 'index' )它类似于http://localhost/moviestock/index.php?controler=home&action=index请给我任何解决方案

1 个答案:

答案 0 :(得分:0)

在你的htaccess中试试这些行:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !\.(css|js|png)$
RewriteRule moviestock/([^/])+/([^/])+/?$ moviestock/index.php?controler=$1&action=$2