Php 页面加载后删除查询字符串

Php 页面加载后删除查询字符串,php,javascript,.htaccess,mod-rewrite,Php,Javascript,.htaccess,Mod Rewrite,我正在开发php,我的网页URL如下 http://localhost/myweb/?action=news http://localhost/myweb/?action=my_profile http://localhost/myweb/?action=my_upload http://localhost/myweb/?action=my_collection http://localhost/myweb/?action=chat http://localhost/myweb/?action=

我正在开发php,我的网页URL如下

http://localhost/myweb/?action=news
http://localhost/myweb/?action=my_profile
http://localhost/myweb/?action=my_upload
http://localhost/myweb/?action=my_collection
http://localhost/myweb/?action=chat
http://localhost/myweb/?action=my_friends
etc
例如,在特定页面中,有一个访问href链接的删除功能

http://localhost/myweb/?action=my_friends&delete=2414535435 <-friends id
并使用javascript访问真正的链接

$('.deleteclass').on('click', function () {
        var name= $(this).attr('nameattr');
        if(confirm('You sure want to delete '+name+'?')){
            window.location='?action=my_friends&delete='+this.id;
        }
    });
问题是,在我处理删除和加载页面后,我不希望地址栏上有完整的链接

http://localhost/myweb/?action=my_friends&delete=2414535435
我需要让它在地址栏上看起来像这样

http://localhost/myweb/?action=my_friends

可能吗?通过mod rewrite,也许?

浏览器加载页面后,您无法删除url

只需在删除或其他操作后执行重定向

header('Location: /myweb/?action=my_friends');
将错误/成功消息添加到会话变量(在执行标题之前在操作脚本中),以便您可以在其他页面上显示它们

$_SESSION['errors'] = "Delete Failed: For Some Reason";
在其他页面上,检查会话变量是否存在,显示它,然后删除它(否则它将留在那里,页面将继续认为存在错误)


不要使用这种模糊处理给自己一种虚假的安全感。任何人都很容易找到需要删除的URL。你需要确保你的php代码中有额外的检查。是的,我注意到了,我在php中提出了更多的要求,如果这个人能执行代码与否。事实上,如果这个人找到了链接,对我来说没关系,但不知何故,我不希望它显示在地址栏上。我使用链接,因为我不知道如何使用按钮(提交),因为在我的情况下,每个表行都有一个删除链接,对于所有/所选项目,没有一个单独的删除按钮。您需要每一行都是单独的表单,或者每个删除提交按钮都包含要删除项目的id。也许最好是每行有一个表格。谢谢你的澄清,这是我现在做的,但它使我需要的一些数据消失了。例如,如果删除失败,则显示错误消息。如果出现错误,则将错误保存到会话变量中,并在其他页面上查找会话变量中的错误。显示会话代码的更新答案
$_SESSION['errors'] = "Delete Failed: For Some Reason";
<?php

if(isset($_SESSION['errors'])) {
   //Do some code to show the error
   ...
   unset($_SESSION['errors']); //delete the error messages
}