htaccess没有正确清除网址

时间:2016-08-04 13:17:35

标签: php apache .htaccess mod-rewrite

我清除了我的mvc应用程序的URL。例如,htaccess清除所有网址,只允许" get" URL = {some_string}。然后我将这个some_string用于我的mvc应用程序。它如此简单快速。但问题是,我的网站上有一个表格。当我写东西并提交时,它会将?url = {written_text}添加到我的网址。我的表格是这样的:

<form action="/" method="get">
 <input type="text name="url">
 <input type="submit>
</form>

通常,例如,我进入链接&#34; {domain_name} / messages&#34;,它会处理&#34;消息&#34;像url = messages。没有问题。但是,当我,例如写&#34;消息&#34;并将表单,网址更改提交到&#34; {domain_name} /?url = messages&#34;。

我不希望这种情况发生。它应该是&#34; {domain_name} / messages&#34;。

我的htaccess文件:

Options -MultiViews

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,NC,L]

AddType application/x-httpd-php .asp .py .pl

1 个答案:

答案 0 :(得分:0)

你不能这样做。 GET是一个HTTP动词,它使用查询参数进行通信。提交表单时,所有参数都将附加到操作表单值。

您收到查询时会使用.htaccess,而非发送时。

如果你真的想这样做,你必须使用AJAX查询来阻止表格的发送,并以你想要的方式重建查询。