我正在使用Xampp,几乎做了所有事情。我有如下htaccess文件:
RewriteEngine On
RewriteRule ^q? query.php [NC]
此外,我已经打开了mod_rewrite模块,并将Allow None
更改为http.conf
Apache文件中的Allow All
。
我希望我的网址是localhost/abc/query.php?q=something&c=something
而不是localhost/q?q=something&c=something
PS:它不是错别字,('q')页面实际上没有扩展名。
此规则应该在DOCUMENT_ROOT/.htaccess
文件中对您有用:
RewriteEngine On
RewriteRule ^q/?$ /abc/query.php [L,NC]
基本上,您使用的是 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
.