Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 htaccess mod rewrite中的控制器和方法转换_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php htaccess mod rewrite中的控制器和方法转换

Php htaccess mod rewrite中的控制器和方法转换,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有一些网址: index.php?controller=user&method=show&id=7 在这个URL中:控制器、方法和显示是我的键 user、show和7是某种价值 我想将URL翻译为: index.php?user/show/7 是否有可能在.htaccess文件中翻译此URL? 现在,我的.htaccess: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_

我有一些网址:

index.php?controller=user&method=show&id=7
在这个URL中:控制器、方法和显示是我的键 user、show和7是某种价值

我想将URL翻译为:

index.php?user/show/7
是否有可能在.htaccess文件中翻译此URL? 现在,我的.htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Cobbler/index.php

我看不出这有什么好处,但是您可以用这个代码替换当前代码

RewriteEngine on
RewriteBase /Cobbler/

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule . ./ [R=301,L,QSA]

RewriteCond %{QUERY_STRING} ^([^/]+)/([^/]+)/([^/]+)$
RewriteRule ^$ index.php?controller=%1&method=%2&id=%3 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

伟大的是否也可以从URL中删除index.php?