dongpu1908 2016-08-04 13:17
浏览 10
已采纳

htaccess没有正确清除Url

I'm clearing the url for my mvc application. For example, htaccess clears all the url and only allow "get" url={some_string}. Then I'm using this some_string for my mvc application. It's so simple and fast. But the problem is, I have a form on my site. When I write something and submit, it adds ?url={written_text} to my url. my form is like this:

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

Normally, for example I enter to the link "{domain_name}/messages", it treats "messages" like url=messages. There is no problem. But when I, for example write "messages" and submit the form, url changes into "{domain_name}/?url=messages".

I don't want this to happen. It should be "{domain_name}/messages".

My htaccess file:

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条回答 默认 最新

  • doujuan9698 2016-08-04 14:27
    关注

    You can't do that this way. GET is a HTTP verb which use query parameters to communicate. When you submit a form, all parameters will be appended to the action form value.

    Your .htaccess is used when you receive a query, not when you send it.

    If you really want to do that you have to use AJAX query to prevent the form to be sent and to rebuild the query the way you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮