Need help about hiding URL contents in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Need help about hiding URL contents in PHP

Post by waseem83 »

How can i hide query string contents from URL through PHP?.
i.e if i have "posting.php?mode=post&f=1"

I want to write it as posting


HOw it can be done in PHP.
KIndly help me for this.
Thank you.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Need help about hiding URL contents in PHP

Post by papa »

URL rewrite is your friend. Or POST the url instead of GET.
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Re: Need help about hiding URL contents in PHP

Post by waseem83 »

If i want to have link then after cliking on link the query string will be shown in URL but i dont want it to be shown in URL.
Like if after clicking on link URL is
"posting.php?mode=post&f=1"

But i want to show it as
"posting"

How it can be done for link click.. ?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Need help about hiding URL contents in PHP

Post by papa »

BornForCode
Forum Contributor
Posts: 147
Joined: Mon Feb 11, 2008 1:56 am

Re: Need help about hiding URL contents in PHP

Post by BornForCode »

Please give also the apache version:

Code: Select all

 
RewriteEngine On 
RewriteRule (.*)\.html $1 [R=301,L] 
 
Or you can use

Code: Select all

 
RewriteEngine on 
RewriteBase / 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP 
RewriteRule ^([^.]+)\.html$ http://www.domain.com/$1 [R=301,L] 
 
Or (i recommend you this one)

Code: Select all

 
RewriteEngine on
RewriteCond %{REQUEST_URI} !(\.[^./]+)$ 
RewriteCond %{REQUEST_fileNAME} !-d 
RewriteCond %{REQUEST_fileNAME} !-f 
RewriteRule (.*) /$1.html [L]
 
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Re: Need help about hiding URL contents in PHP

Post by waseem83 »

Thank you very much for help.
Post Reply