Php 如何重写get方法传递了值的url并将其传递到另一个页面?
我使用Xampp,几乎做了所有事情。 我拥有htaccess文件,如下所示: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
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]
谢谢阿努巴瓦。。。它成功了,犯了一个愚蠢的错误,没有在正则表达式中添加“$”符号…:)