Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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
使用htaccess和php从mvc中的url请求参数_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

使用htaccess和php从mvc中的url请求参数

使用htaccess和php从mvc中的url请求参数,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,真正的url格式是 http://localhost/myfolder/index.php?url=login/register&step=1 修改后我得到 http://localhost/myfolder/login/register/step/1 很好,但是如何在php文件中获取step的值。如果我执行$\u get['step'],那么我将一无所获 我的htaccess Options -MultiViews # turn rewriting on RewriteEngin

真正的url格式是

http://localhost/myfolder/index.php?url=login/register&step=1
修改后我得到

http://localhost/myfolder/login/register/step/1
很好,但是如何在php文件中获取step的值。如果我执行$\u get['step'],那么我将一无所获

我的htaccess

Options -MultiViews

# turn rewriting on
RewriteEngine On

# When using the script within a sub-folder, put this path here, like /mysubfolder/
# If your app is in the root of your web folder, then please delete this line or comment it out
RewriteBase /mybb/

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


RewriteRule ^(.*)/(.*) index.php?url=$0&step=$2 [L,QSA]
将规则更改为:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)(?:/(step)/([0-9]+))?/?$ index.php?url=$1&$2=$3 [NC,L,QSA]

显示您当前的规则?我已经用添加的htaccess代码更新了问题。@Raj,您可能会发现这篇帖子很有用:谢谢@tereško,我将在周末看一看。您真是太棒了。非常感谢您救了我一命。答案已被接受,但无法投票,因为上面说至少需要15个声誉。抱歉。