Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法重写MVC项目的url_Php_Apache_.htaccess_Url Rewriting - Fatal编程技术网

Php 无法重写MVC项目的url

Php 无法重写MVC项目的url,php,apache,.htaccess,url-rewriting,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] 当我点击urlhttp://localhost/moviestock/home/indexprint

我被困在这里,我尝试过谷歌搜索,但找不到解决办法

Options +FollowSymLinks
RewriteEngine On

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

当我点击url
http://localhost/moviestock/home/index
print\r($\u-GET)
然后我得到了这个输出
Array()
这意味着
$\u-GET==Array()
但是我希望$\u-GET像这样
$\u-GET==Array('controller'=>'home','action'=>'index'))
它类似于
http://localhost/moviestock/index.php?controler=home&action=index
请给我任何解决方案

在您的htaccess中尝试以下几行:

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