Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 查询字符串的htaccess重写_.htaccess - Fatal编程技术网

.htaccess 查询字符串的htaccess重写

.htaccess 查询字符串的htaccess重写,.htaccess,.htaccess,好的,我是个新手,非常感谢你的帮助,谢谢 如何在.htaccess中正确重写此内容 因此,我的url中有一个查询字符串: /?url=contact 我只想删除查询字符串 /contact 帮忙?我搜索了谷歌,现在正在学习语法,但事实仍然是,我还不知道怎么做。多谢大家 RewriteCond %{QUERY_STRING} url=(.*) RewriteRule index.html %1 (或者,如果不是index.html、index.php之类的内容,则可以选择其他内容) 您

好的,我是个新手,非常感谢你的帮助,谢谢

如何在.htaccess中正确重写此内容

因此,我的url中有一个查询字符串:

 /?url=contact
我只想删除查询字符串

 /contact
帮忙?我搜索了谷歌,现在正在学习语法,但事实仍然是,我还不知道怎么做。多谢大家

RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule index.html  %1
(或者,如果不是index.html、index.php之类的内容,则可以选择其他内容)

您需要捕获RewriteRule通常不会查看的查询字符串,并使用%1反向引用,而不是像在RewriteRule中捕获时那样使用$1。请尝试以下操作:

RewriteEngine On
RewriteRule ^(.*)$ /index.php?url=$1 [L]
对于您网站上的用户,他们将看到并导航到:

http://example.com/contact
但真正的页面应该是这样的:

http://example.com/index.php?url=contact
此位,
[L]
告诉服务器这是重写规则的最后一行,要停止。

这是我的解决方案:


RewriteRule^(.*)$index.php?url=$1[L,QSA]

我按照您在xampp.htaccess文件中的建议添加了规则。当我尝试重新加载页面时,它将重定向到localhost/dashboard页面。有什么遗漏吗?@Tekson,这也发生在我身上,这是由于/index.php位。将其更改为index.php,不带斜杠。此规则对我不适用。当我添加您的规则时,页面将重定向到
xampp
的欢迎页面。