Jump to content

Remove Query String


pokonipo

Recommended Posts

I want to have a PHP script that will remove the query string from a URL when the server sends the page to the user. I want the script to work regardless of how short or how long (or existent or nonexistent) the query string might be. So, for example, if the user types any of these URLs into the address bar of their browser...

 

http://example.com/page.php

http://example.com/page.php?

http://example.com/page.php?a

http://example.com/page.php?a=

http://example.com/page.php?a=b

http://example.com/page.php?anything=anything&etcetera=etcetera

 

...this URL will appear in the address bar of their browser when the server sends the page to the user:

 

http://example.com/page.php

 

Thanks in advance for your help.

 

Link to comment
https://forums.phpfreaks.com/topic/80406-remove-query-string/
Share on other sites

That info about mod_rewrite is interesting, and I thank you for it. But it does not directly apply to my original post. Notice that I said this in my original post: "I want to have a PHP script..." Mod_rewrite is not a PHP methodology. Please post the code for a PHP script that will accomplish what I described in my my original post. Thank you very much.

 

Link to comment
https://forums.phpfreaks.com/topic/80406-remove-query-string/#findComment-407700
Share on other sites

  • 10 months later...

I am re-opening this thread several months after I started it because I have now finally discovered that there is a PHP solution to what I wrote about in my OP (in spite of the fact that all of the responses to my OP seemed to imply that there is no PHP solution). Here is the PHP solution:

 


<script language="php">

if($_get){header("location: http://example.com/page.php");}

</script>

blah blah blah 

 

By the way, make sure there is no content (not even white space) above that PHP code. Put all content below it.

 

 

Link to comment
https://forums.phpfreaks.com/topic/80406-remove-query-string/#findComment-669163
Share on other sites

Zoonose: what you are essentially saying is that I should have known the solution to my problem before I asked for a solution. That's ridiculous. How was I supposed to ask for a 'redirect' when I had absolutely no idea what the solution was to my problem?! Contrary to Zoonose's view of it, anybody who scrolls to the top of this page can see that my OP was very clearly worded.

 

Link to comment
https://forums.phpfreaks.com/topic/80406-remove-query-string/#findComment-669175
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.