简体   繁体   中英

how to hide the url from a new tab in the frameset

Here is my problem:

I want to hide the parameters in url, so any page only can display www.website.com

I added a frameset for the index.php page,

it's perfect when user click any link in this page,

but if user open a link by right click -> open in new tab or window,

the whole URL with parameters will be shown,

any idea to prevent when user open a page in frameset by open in new tab?

Generally to accomplish this you need to set up the server to act in this way. It's generally refered to as URI's, or "Pretty URI's". This is also a key component in designing your app in RESTful senses.

If you have access to your servers configuration and are running a LAMP stack you can accomplish this with .htaccess files. But you will still need your server-side script to handle the rest of the requests.

Here's an example .htaccess file that will remove the extension and query:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php /$1 [R=301,L]

But you should refer to RESTful anyways if you definatly want precise URI's http://phpmaster.com/rest-can-you-do-more-than-spell-it-1/

And another tutorial on .htaccess and "Pretty URLs" http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

Well, hiding URLs like this is generally not a good idea, but you could try this:

<a href="somepage.php" onclick="location.href=this.href;return false;">Link</a>

You can also use some simple JavaScript so you don't have to manually add the event handler to each link:

document.body.addEventListener("click",function(e) {
    var t = e.srcElement || e.target;
    if( !t.tagName) t = t.parentNode;
    if( t.tagName.toLowerCase() == "a") {
        location.href = t.href;
        return false;
    }
},false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM