user2660611
user2660611

Reputation: 65

how to hide GET variable from url

i'v been stuck with this <a href="profile.php?u=<?php echo $uiname ?>"/> , i'm trying to hide the $_GET variable but no success. what i'm trying to achieve is something like www.mywebsitename.com/profile/name or www.mywebsite.com/name instead of

profile.php?u=name

is it possible to do so ?

Upvotes: 4

Views: 9550

Answers (1)

Bora
Bora

Reputation: 10717

For Your URL: http://localhost/ifinal/profile/myname

You can use like with htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ifinal/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^profile/(.*) profile.php?u=$1
</IfModule>

If your site not underfolder, use just RewriteBase /

And use HTML

<a href="profile/<?php echo $uiname; ?>">
   <?php echo $uiname; ?>
</a>

Upvotes: 3

Related Questions