Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.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 如何重写get方法传递了值的url并将其传递到另一个页面?_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 如何重写get方法传递了值的url并将其传递到另一个页面?

Php 如何重写get方法传递了值的url并将其传递到另一个页面?,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我使用Xampp,几乎做了所有事情。 我拥有htaccess文件,如下所示: RewriteEngine On RewriteRule ^q? query.php [NC] 此外,我已打开mod_rewrite模块,并将http.confApache文件中的所有Allow None更改为Allow all 我希望我的url是localhost/abc/query.php?q=something&c=something而不是localhost/q?q=something&c=something

我使用Xampp,几乎做了所有事情。 我拥有htaccess文件,如下所示:

RewriteEngine On

RewriteRule ^q? query.php [NC]
此外,我已打开mod_rewrite模块,并将
http.conf
Apache文件中的所有
Allow None
更改为
Allow all

我希望我的url是
localhost/abc/query.php?q=something&c=something
而不是
localhost/q?q=something&c=something


PS:这不是打字错误,('q')页面实际上没有扩展。

基本上,您使用的是q/index.php,这就是为什么扩展被隐藏,因为index.php被隐藏。你想做的是:

<form action="abc/query.php" name="query" method="GET">
<input type="text" name="q" />
<input type="text" name="c" />
<input type="submit" />
</form>


然后它应该显示为
/abc/query.php?q=randomtext&c=randomtext
此规则应该适用于
文档根/.htaccess
文件:

RewriteEngine On

RewriteRule ^q/?$ /abc/query.php [L,NC]

谢谢阿努巴瓦。。。它成功了,犯了一个愚蠢的错误,没有在正则表达式中添加“$”符号…:)