Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.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框架中的GET方法_Php_.htaccess_Url Routing - Fatal编程技术网

php-mvc框架中的GET方法

php-mvc框架中的GET方法,php,.htaccess,url-routing,Php,.htaccess,Url Routing,我自己从头开始编写PHP MVC框架,我使用.htaccess规则将所有请求重定向到我的引导程序: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ bootstrap.php?url=$1 [PT,L 现在的问题是,我不能再在表单上使用GET方法,当我想使用GET方法提交搜索表单时,GET参数不会发送,但它可以与post一起使用

我自己从头开始编写PHP MVC框架,我使用
.htaccess
规则将所有请求重定向到我的引导程序:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ bootstrap.php?url=$1 [PT,L

现在的问题是,我不能再在表单上使用GET方法,当我想使用GET方法提交搜索表单时,GET参数不会发送,但它可以与post一起使用,但它不适合搜索表单。

这是我自己的MVC使用的.htaccess,您可以尝试一下吗

例如用法:localhost/your\u webroot/controller/action/?get\u parameters=anything

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ your_webroot/index.php?rt=$1 [L,QSA]
# This denies all web access to your .ini file. 
<files config.base.ini>
  order deny,allow
  deny from all
</files>
<files errorlogs.log>
  order deny,allow
  deny from all
</files>
重新编写引擎打开
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$your_webroot/index.php?rt=$1[L,QSA]
#这将拒绝对.ini文件的所有web访问。
命令拒绝,允许
全盘否定
命令拒绝,允许
全盘否定

这对我很有效。只需将其添加到.htaccess中即可

Options -Multiviews

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
所以你可以使用这个URL

http://localhost:81/mywebsite/public/search?query=ironman
还有这个

http://localhost:81/mywebsite/public/search/ironman

我知道bootstrap.php在根目录中吗?请尝试
[QSA,PT,L]
,如果您可以发布一个示例,说明您的表单或URL在使用GET时的样子,这会有所帮助。在WWW文件夹中,我使用类似的htaccess将所有请求从根目录中的index.php重定向到WWW中的bootstrapfolder@Prix:谢谢,司令部做到了